tarpc last attempt
This commit is contained in:
parent
d490ff1024
commit
0012b1b585
@ -19,8 +19,8 @@ mod battle;
|
||||
mod skill;
|
||||
mod net;
|
||||
|
||||
use net::server;
|
||||
use net::run_server;
|
||||
|
||||
fn main() {
|
||||
server()
|
||||
run_server()
|
||||
}
|
||||
30
src/net.rs
Normal file → Executable file
30
src/net.rs
Normal file → Executable file
@ -19,7 +19,7 @@ impl FutureService for HelloServer {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn server() {
|
||||
pub fn run_server() {
|
||||
let mut reactor = reactor::Core::new().unwrap();
|
||||
let (mut handle, server) = HelloServer
|
||||
.listen(
|
||||
@ -28,16 +28,24 @@ pub fn server() {
|
||||
server::Options::default(),
|
||||
)
|
||||
.unwrap();
|
||||
handle.wait();
|
||||
reactor.handle().spawn(server);
|
||||
}
|
||||
|
||||
// let options = client::Options::default().handle(reactor.handle());
|
||||
// reactor
|
||||
// .run(
|
||||
// FutureClient::connect(handle.addr(), options)
|
||||
// .map_err(|e| panic!("{:?}", e))
|
||||
// .and_then(|client| client.hello("Mom".to_string()))
|
||||
// .map(|resp| println!("{}", resp)),
|
||||
// )
|
||||
// .unwrap();
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn connect() {
|
||||
let mut reactor = reactor::Core::new().unwrap();
|
||||
let options = client::Options::default().handle(reactor.handle());
|
||||
reactor
|
||||
.run(
|
||||
FutureClient::connect("localhost:10000".first_socket_addr(), options)
|
||||
.map_err(|e| panic!("{:?}", e))
|
||||
.and_then(|client| client.hello("Mom".to_string()))
|
||||
.map(|resp| println!("{}", resp)),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user