Finish the multiplex implementation

This commit is contained in:
Tim Kuehn
2016-09-26 23:44:22 -07:00
parent 4a63064cbd
commit 5bace01f2b
7 changed files with 79 additions and 85 deletions

View File

@@ -13,13 +13,13 @@ use serde::{Deserialize, Serialize};
use std::io;
use std::net::SocketAddr;
use tokio_core::reactor::Handle;
use tokio_proto::pipeline;
use tokio_proto::{self as proto, multiplex};
use tokio_proto::server::{self, ServerHandle};
use tokio_service::NewService;
use util::Never;
/// A message from server to client.
pub type Response<T, E> = pipeline::Message<Result<T, WireError<E>>, Empty<Never, io::Error>>;
pub type Response<T, E> = proto::Message<Result<T, WireError<E>>, Empty<Never, io::Error>>;
/// Spawns a service that binds to the given address and runs on the default reactor core.
pub fn listen<S, Req, Resp, E>(addr: SocketAddr, new_service: S) -> ListenFuture
@@ -48,7 +48,7 @@ pub fn listen_with<S, Req, Resp, E>(addr: SocketAddr, new_service: S, handle: &H
E: Serialize,
{
server::listen(handle, addr, move |stream| {
pipeline::Server::new(new_service.new_service()?, Framed::new(stream))
Ok(multiplex::Server::new(new_service.new_service()?, Framed::new(stream)))
})
}