mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-18 22:21:50 +03:00
augmented websocket push to contain the type of the message conditionally
This commit is contained in:
parent
5e9ea796ed
commit
d536cd116f
@ -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) {
|
||||
|
@ -149,6 +149,7 @@ pub enum WsMessageType {
|
||||
Binary,
|
||||
Ping,
|
||||
Pong,
|
||||
Close,
|
||||
}
|
||||
|
||||
/// Part of the Response type issued by http_server
|
||||
|
Loading…
Reference in New Issue
Block a user