diff --git a/src/http/server.rs b/src/http/server.rs index f3f13b72..e6436bf4 100644 --- a/src/http/server.rs +++ b/src/http/server.rs @@ -651,6 +651,18 @@ async fn maintain_websocket( match read { Some(Ok(msg)) => { + let ws_msg_type = if msg.is_text() { + WsMessageType::Text + } else if msg.is_binary() { + WsMessageType::Binary + } else if msg.is_ping() { + WsMessageType::Ping + } else if msg.is_pong() { + WsMessageType::Pong + } else { + WsMessageType::Close + }; + let _ = send_to_loop.send(KernelMessage { id: rand::random(), source: Address { @@ -667,7 +679,7 @@ async fn maintain_websocket( expects_response: None, ipc: serde_json::to_vec(&HttpServerRequest::WebSocketPush { channel_id, - message_type: WsMessageType::Binary, + message_type: ws_msg_type, }).unwrap(), metadata: Some("ws".into()), }), @@ -1003,7 +1015,8 @@ async fn handle_app_message( } else { warp::ws::Message::pong(payload.bytes) } - } + }, + WsMessageType::Close => { unreachable!(); } }; // Send to the websocket if registered if let Some(got) = ws_senders.get(&channel_id) { diff --git a/src/http/types.rs b/src/http/types.rs index cdc87ef0..46016cf2 100644 --- a/src/http/types.rs +++ b/src/http/types.rs @@ -149,6 +149,7 @@ pub enum WsMessageType { Binary, Ping, Pong, + Close, } /// Part of the Response type issued by http_server