mirror of https://github.com/fafhrd91/actix-web
Change WebsocketContext to accept Bytes for ping
This needed to change the tests: pong no longer takes a reference. This makes the interface more similar to "test" and "binary".
This commit is contained in:
parent
e374f3c97c
commit
e6f8686155
|
@ -345,14 +345,14 @@ where
|
|||
|
||||
/// Send ping frame
|
||||
#[inline]
|
||||
pub fn ping(&mut self, message: &str) {
|
||||
self.write_raw(Message::Ping(message.to_string()));
|
||||
pub fn ping<B: Into<Bytes>>(&mut self, message: B) {
|
||||
self.write_raw(Message::Ping(message.into()));
|
||||
}
|
||||
|
||||
/// Send pong frame
|
||||
#[inline]
|
||||
pub fn pong(&mut self, message: &str) {
|
||||
self.write_raw(Message::Pong(message.to_string()));
|
||||
pub fn pong<B: Into<Bytes>>(&mut self, message: B) {
|
||||
self.write_raw(Message::Pong(message.into()));
|
||||
}
|
||||
|
||||
/// Send close frame
|
||||
|
|
|
@ -15,7 +15,7 @@ impl Actor for Ws {
|
|||
impl StreamHandler<ws::Message, ws::ProtocolError> for Ws {
|
||||
fn handle(&mut self, msg: ws::Message, ctx: &mut Self::Context) {
|
||||
match msg {
|
||||
ws::Message::Ping(msg) => ctx.pong(&msg),
|
||||
ws::Message::Ping(msg) => ctx.pong(msg),
|
||||
ws::Message::Text(text) => ctx.text(text),
|
||||
ws::Message::Binary(bin) => ctx.binary(bin),
|
||||
ws::Message::Close(reason) => ctx.close(reason),
|
||||
|
|
Loading…
Reference in New Issue