Skip to content

Commit 6f804c6

Browse files
committed
add server setup acceptor impl.
1 parent 3f99aa6 commit 6f804c6

26 files changed

+313
-176
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rsocket_rust"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
authors = ["Jeffsky <[email protected]>"]
55
edition = "2018"
66
license = "Apache-2.0"

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,39 @@
1515
1616
### Server
1717
```rust
18+
extern crate bytes;
1819
extern crate futures;
1920
extern crate rsocket_rust;
2021

22+
use bytes::Bytes;
2123
use futures::prelude::*;
2224
use rsocket_rust::prelude::*;
2325

2426
#[test]
2527
fn test_serve() {
2628
RSocketFactory::receive()
2729
.transport(URI::Tcp("127.0.0.1:7878"))
28-
.acceptor(Box::new(MockResponder))
30+
.acceptor(|setup, sending_socket| {
31+
println!("accept setup: {:?}", setup);
32+
// TODO: use tokio runtime?
33+
std::thread::spawn(move || {
34+
let resp = sending_socket
35+
.request_response(
36+
Payload::builder()
37+
.set_data(Bytes::from("Hello Client!"))
38+
.build(),
39+
)
40+
.wait()
41+
.unwrap();
42+
println!(">>>>> response success: {:?}", resp);
43+
});
44+
Box::new(MockResponder)
45+
})
2946
.serve()
3047
.wait()
3148
.unwrap();
3249
}
50+
3351
```
3452

3553
### Client
@@ -59,6 +77,10 @@ fn test_client() {
5977
}
6078
```
6179

80+
## Dependencies
81+
1. [Tokio](https://tokio.rs/)
82+
2. [futures-rs](http://rust-lang-nursery.github.io/futures-rs/)
83+
6284
## TODO
6385
- Codec
6486
- [x] Setup

src/core/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::sync::atomic::{AtomicU32, Ordering};
22
use std::sync::Arc;
33

4-
#[derive(Debug)]
4+
#[derive(Debug, Clone)]
55
pub struct StreamID {
66
inner: Arc<AtomicU32>,
77
}

src/core/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ mod socket;
44
mod spi;
55

66
pub use callers::*;
7-
pub use socket::{DuplexSocket, DuplexSocketBuilder,EmptyRSocket};
7+
pub use socket::{DuplexSocket, DuplexSocketBuilder,EmptyRSocket,Acceptor};
88
pub use spi::{RSocket,MockResponder};

0 commit comments

Comments
 (0)