diff --git a/src/http/server.rs b/src/http/server.rs index 812cf14c..8bf7acd1 100644 --- a/src/http/server.rs +++ b/src/http/server.rs @@ -436,6 +436,31 @@ async fn maintain_websocket( let (ws_sender, mut ws_receiver) = tokio::sync::mpsc::channel(100); ws_senders.insert(ws_channel_id, (owner_process.clone(), ws_sender)); + // send a message to the process associated with this channel + // notifying them that the channel is now open + let _ = send_to_loop + .send(KernelMessage { + id: rand::random(), + source: Address { + node: our.to_string(), + process: HTTP_SERVER_PROCESS_ID.clone(), + }, + target: Address { + node: our.to_string(), + process: owner_process.clone(), + }, + rsvp: None, + message: Message::Request(Request { + inherit: false, + expects_response: None, + ipc: serde_json::to_vec(&HttpServerAction::WebSocketOpen(ws_channel_id)).unwrap(), + metadata: None, + }), + payload: None, + signed_capabilities: None, + }) + .await; + // respond to the client notifying them that the channel is now open let Ok(()) = write_stream .send(warp::ws::Message::text( diff --git a/src/http/types.rs b/src/http/types.rs index 31ce989a..ecba6711 100644 --- a/src/http/types.rs +++ b/src/http/types.rs @@ -72,8 +72,8 @@ pub enum HttpServerAction { cache: bool, }, /// Processes will RECEIVE this kind of request when a client connects to them. - /// If a process does not want this websocket open, they can respond with an - /// [`enum@HttpServerAction::WebSocketClose`] message. + /// If a process does not want this websocket open, they should issue a *request* + /// containing a [`enum@HttpServerAction::WebSocketClose`] message and this channel ID. WebSocketOpen(u32), /// Processes can both SEND and RECEIVE this kind of request. /// When sent, expects a payload containing the WebSocket message bytes to send.