include payload into request

This commit is contained in:
Nikolay Kim 2017-11-26 19:00:57 -08:00
parent 32483735ba
commit eb7f48a1c6
20 changed files with 218 additions and 206 deletions

View file

@ -83,15 +83,14 @@ impl Actor for MyWebSocket {
impl Route for MyWebSocket {
type State = ();
fn request(req: &mut HttpRequest,
payload: Payload, ctx: &mut HttpContext<Self>) -> RouteResult<Self>
fn request(req: &mut HttpRequest, ctx: &mut HttpContext<Self>) -> RouteResult<Self>
{
// websocket handshake
let resp = ws::handshake(req)?;
// send HttpResponse back to peer
ctx.start(resp);
// convert bytes stream to a stream of `ws::Message` and handle stream
ctx.add_stream(ws::WsStream::new(payload));
ctx.add_stream(ws::WsStream::new(req));
Reply::async(MyWebSocket)
}
}