Use tokio-codec. (#271)

This commit is contained in:
Toralf Wittner
2018-06-22 16:12:23 +02:00
committed by GitHub
parent 75df40010b
commit 16967abda7
21 changed files with 40 additions and 26 deletions

View File

@ -86,6 +86,7 @@ extern crate log;
extern crate multistream_select;
extern crate parking_lot;
extern crate rand;
extern crate tokio_codec;
extern crate tokio_io;
use bytes::{BufMut, Bytes, BytesMut};
@ -101,7 +102,7 @@ use std::error::Error;
use std::io::Error as IoError;
use std::iter;
use std::sync::Arc;
use tokio_io::codec::{Decoder, Encoder};
use tokio_codec::{Decoder, Encoder, Framed};
use tokio_io::{AsyncRead, AsyncWrite};
/// Represents a prototype for an upgrade to handle the ping protocol.
@ -160,8 +161,7 @@ where
// TODO: can't figure out how to make it work without using an Arc/Mutex
let expected_pongs = Arc::new(Mutex::new(HashMap::with_capacity(4)));
let sink_stream = socket
.framed(Codec)
let sink_stream = Framed::new(socket, Codec)
.map(|msg| Message::Received(msg.freeze()));
let (sink, stream) = sink_stream.split();