Browse Source

Move packet types from packet_connection to packet.

Mathias Gottschlag 5 years ago
parent
commit
a7131f9236
4 changed files with 22 additions and 21 deletions
  1. 12
    12
      src/network/client.rs
  2. 1
    1
      src/network/mod.rs
  3. 6
    6
      src/network/packet.rs
  4. 3
    2
      src/network/server.rs

+ 12
- 12
src/network/client.rs View File

1
 use futures::Future;
1
 use futures::Future;
2
-use futures::task::{Context, Poll};
3
-use core::pin::Pin;
2
+//use futures::task::{Context, Poll};
3
+//use core::pin::Pin;
4
 use tokio::stream::Stream;
4
 use tokio::stream::Stream;
5
-use async_tungstenite::{tokio::connect_async, tungstenite::Message, WebSocketStream};
6
-use url::Url;
5
+//use async_tungstenite::{tokio::connect_async, tungstenite::Message, WebSocketStream};
6
+//use url::Url;
7
 
7
 
8
-use super::packet_connection::IncomingPacket;
8
+use super::packet::IncomingPacket;
9
 
9
 
10
 use std::time::Duration;
10
 use std::time::Duration;
11
 
11
 
23
 
23
 
24
 pub trait ServerEventStream<PacketType>: Stream<Item = PacketType> {}
24
 pub trait ServerEventStream<PacketType>: Stream<Item = PacketType> {}
25
 
25
 
26
-pub struct WSRPCInterface<PacketType, Stream> {
26
+/*pub struct WSRPCInterface<PacketType, Stream> {
27
     // TODO
27
     // TODO
28
     _unused: PacketType,
28
     _unused: PacketType,
29
     stream: WebSocketStream<Stream>,
29
     stream: WebSocketStream<Stream>,
30
 }
30
 }
31
 
31
 
32
 impl<P, S> WSRPCInterface<P, S> {
32
 impl<P, S> WSRPCInterface<P, S> {
33
-    fn create<P2, S2>(ws_stream: WebSocketStream<S2>) -> (Self, WSServerEventStream<P2>) {
33
+    fn create<P2, S2>(_ws_stream: WebSocketStream<S2>) -> (Self, WSServerEventStream<P2>) {
34
         // TODO
34
         // TODO
35
         panic!("Not yet implemented.");
35
         panic!("Not yet implemented.");
36
     }
36
     }
80
         // TODO
80
         // TODO
81
         panic!("Not yet implemented.");
81
         panic!("Not yet implemented.");
82
     }
82
     }
83
-}
84
-
83
+}*/
85
 
84
 
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();
85
+pub async fn low_level_integration_test_client(_address: String) {
86
+    //let url = Url::parse(&address).unwrap();
87
+    //let (mut ws_stream, _) = connect_async(url).await.unwrap();
89
     // TODO
88
     // TODO
89
+    panic!("Not yet implemented.");
90
 }
90
 }

+ 1
- 1
src/network/mod.rs View File

1
 pub mod client;
1
 pub mod client;
2
-pub mod packet_connection;
2
+pub mod packet;
3
 pub mod server;
3
 pub mod server;

src/network/packet_connection.rs → src/network/packet.rs View File

27
 //! a way that no such temporal information is necessary to process the events.
27
 //! a way that no such temporal information is necessary to process the events.
28
 //! TODO: Example to demonstrate the problem.
28
 //! TODO: Example to demonstrate the problem.
29
 
29
 
30
-use serde::de::DeserializeOwned;
30
+//use futures::sink::Sink;
31
+//use futures::stream::Stream;
32
+//use serde::de::DeserializeOwned;
31
 use serde::{Deserialize, Serialize};
33
 use serde::{Deserialize, Serialize};
32
 
34
 
33
 pub const SERVER_EVENT_ID: u32 = u32::max_value();
35
 pub const SERVER_EVENT_ID: u32 = u32::max_value();
34
 
36
 
35
-pub trait PacketConnection {
36
-    type Payload: Serialize + DeserializeOwned;
37
-
38
-    // TODO
39
-}
37
+//pub trait PacketConnection: Sink<&Self::Payload> + Stream<IncomingPacket<Payload>> {
38
+//    type Payload: Serialize + DeserializeOwned;
39
+//}
40
 
40
 
41
 /// Type which holds a byte vector received via the network and which allows access to the
41
 /// Type which holds a byte vector received via the network and which allows access to the
42
 /// deserialized packet.
42
 /// deserialized packet.

+ 3
- 2
src/network/server.rs View File

1
-use super::packet_connection::IncomingPacket;
1
+use super::packet::IncomingPacket;
2
 
2
 
3
 // Trait that is implemented by any RPC server to process incoming calls.
3
 // Trait that is implemented by any RPC server to process incoming calls.
4
 trait RPCServer {
4
 trait RPCServer {
27
 }
27
 }
28
 
28
 
29
 impl LowLevelIntegrationTestServer {
29
 impl LowLevelIntegrationTestServer {
30
-    pub async fn start(bind_address: &str) -> LowLevelIntegrationTestServer {
30
+    pub async fn start(_bind_address: &str) -> LowLevelIntegrationTestServer {
31
         // TODO
31
         // TODO
32
         LowLevelIntegrationTestServer{}
32
         LowLevelIntegrationTestServer{}
33
     }
33
     }
36
         // TODO
36
         // TODO
37
     }
37
     }
38
 }
38
 }
39
+

Loading…
Cancel
Save