diff --git a/src/ws/decoder.rs b/src/ws/decoder.rs index 702681e..cce8f44 100644 --- a/src/ws/decoder.rs +++ b/src/ws/decoder.rs @@ -124,7 +124,7 @@ impl Decoder { protocol::op::CONTINUATION_FRAME => WebsocketFrame::Continuation(self.fin, payload), protocol::op::PING => WebsocketFrame::Ping(payload), protocol::op::CONNECTION_CLOSE => WebsocketFrame::Close(payload), - _ => return Err(Error::Protocol("unknown op_code")), + _ => WebsocketFrame::Unknown(self.op_code, payload), }; self.decode_state = DecodeState::ReadingHeader; return Ok(Some(frame)); diff --git a/src/ws/mod.rs b/src/ws/mod.rs index b6835fc..d7e8002 100644 --- a/src/ws/mod.rs +++ b/src/ws/mod.rs @@ -94,6 +94,9 @@ pub enum WebsocketFrame { /// Server has sent close frame. The websocket will be closed as a result. This frame is not /// exposed to the user. Close(&'static [u8]), + /// Server has sent an opcode that boomnet does not support. It is up to the user to handle the + /// outcome of an Unknown opcode + Unknown(u8, &'static [u8]), } /// Websocket client that owns underlying stream.