|
|
@@ -1,5 +1,9 @@
|
|
1
|
1
|
use futures::Future;
|
|
|
2
|
+use futures::task::{Context, Poll};
|
|
|
3
|
+use core::pin::Pin;
|
|
2
|
4
|
use tokio::stream::Stream;
|
|
|
5
|
+use async_tungstenite::{tokio::connect_async, tungstenite::Message, WebSocketStream};
|
|
|
6
|
+use url::Url;
|
|
3
|
7
|
|
|
4
|
8
|
use super::packet_connection::IncomingPacket;
|
|
5
|
9
|
|
|
|
@@ -19,6 +23,68 @@ pub trait RPC: Future {
|
|
19
|
23
|
|
|
20
|
24
|
pub trait ServerEventStream<PacketType>: Stream<Item = PacketType> {}
|
|
21
|
25
|
|
|
|
26
|
+pub struct WSRPCInterface<PacketType, Stream> {
|
|
|
27
|
+ // TODO
|
|
|
28
|
+ _unused: PacketType,
|
|
|
29
|
+ stream: WebSocketStream<Stream>,
|
|
|
30
|
+}
|
|
|
31
|
+
|
|
|
32
|
+impl<P, S> WSRPCInterface<P, S> {
|
|
|
33
|
+ fn create<P2, S2>(ws_stream: WebSocketStream<S2>) -> (Self, WSServerEventStream<P2>) {
|
|
|
34
|
+ // TODO
|
|
|
35
|
+ panic!("Not yet implemented.");
|
|
|
36
|
+ }
|
|
|
37
|
+}
|
|
|
38
|
+
|
|
|
39
|
+impl<P, S> RPCInterface for WSRPCInterface<P, S> {
|
|
|
40
|
+ type PacketType = P;
|
|
|
41
|
+ type NetworkError = String; // TODO
|
|
|
42
|
+
|
|
|
43
|
+ type Call = WSRPC<Self::PacketType>;
|
|
|
44
|
+
|
|
|
45
|
+ fn call(call: &Self::PacketType) -> Self::Call {
|
|
|
46
|
+ // TODO
|
|
|
47
|
+ panic!("Not yet implemented.");
|
|
|
48
|
+ }
|
|
|
49
|
+}
|
|
|
50
|
+
|
|
|
51
|
+pub struct WSRPC<PacketType> {
|
|
|
52
|
+ // TODO
|
|
|
53
|
+ _unused: PacketType,
|
|
|
54
|
+}
|
|
|
55
|
+
|
|
|
56
|
+impl<P> Future for WSRPC<P> {
|
|
|
57
|
+ type Output = Result<IncomingPacket<P>, String>;
|
|
|
58
|
+
|
|
|
59
|
+ fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
|
|
60
|
+ // TODO
|
|
|
61
|
+ panic!("Not yet implemented.");
|
|
|
62
|
+ }
|
|
|
63
|
+}
|
|
|
64
|
+
|
|
|
65
|
+impl<P> RPC for WSRPC<P> {
|
|
|
66
|
+ fn with_timeout(self, timeout: Duration) -> Self {
|
|
|
67
|
+ // TODO
|
|
|
68
|
+ panic!("Not yet implemented.");
|
|
|
69
|
+ }
|
|
|
70
|
+}
|
|
|
71
|
+
|
|
|
72
|
+struct WSServerEventStream<PacketType> {
|
|
|
73
|
+ _unused: PacketType,
|
|
|
74
|
+}
|
|
|
75
|
+
|
|
|
76
|
+impl<P> Stream for WSServerEventStream<P> {
|
|
|
77
|
+ type Item = P;
|
|
|
78
|
+
|
|
|
79
|
+ fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
|
|
|
80
|
+ // TODO
|
|
|
81
|
+ panic!("Not yet implemented.");
|
|
|
82
|
+ }
|
|
|
83
|
+}
|
|
|
84
|
+
|
|
|
85
|
+
|
|
22
|
86
|
pub async fn low_level_integration_test_client(address: String) {
|
|
|
87
|
+ let url = Url::parse(&address).unwrap();
|
|
|
88
|
+ let (mut ws_stream, _) = connect_async(url).await.unwrap();
|
|
23
|
89
|
// TODO
|
|
24
|
90
|
}
|