MCPcopy Create free account
hub / github.com/Botloader/botloader / handle_ws_message

Method handle_ws_message

components/webapi/src/routes/ws.rs:147–163  ·  view source on GitHub ↗
(&mut self, msg: Message)

Source from the content-addressed store, hash-verified

145 }
146
147 async fn handle_ws_message(&mut self, msg: Message) -> WsResult {
148 match msg {
149 Message::Text(s) => {
150 let cmd: WsCommand =
151 serde_json::from_str(&s).map_err(|_| WsCloseReason::JsonDecodeError)?;
152 self.handle_ws_command(cmd).await
153 }
154 Message::Binary(b) => {
155 let cmd: WsCommand =
156 serde_json::from_slice(&b).map_err(|_| WsCloseReason::JsonDecodeError)?;
157 self.handle_ws_command(cmd).await
158 }
159 Message::Ping(d) => self.send(Message::Pong(d)).await,
160 Message::Pong(_) => Ok(()),
161 Message::Close(_) => Err(WsCloseReason::ClientDisconnected),
162 }
163 }
164
165 async fn handle_ws_command(&mut self, cmd: WsCommand) -> WsResult {
166 match &self.state {

Callers 1

handle_ws_rcvMethod · 0.80

Calls 2

handle_ws_commandMethod · 0.80
sendMethod · 0.45

Tested by

no test coverage detected