map the response of the ws.send call into a LuaError

This commit is contained in:
AsynchronousMatrix 2023-07-19 12:48:54 +01:00
parent 4ed7cafc77
commit e5a844ecec

View file

@ -154,8 +154,7 @@ where
{ {
let mut ws = socket.write_stream.lock().await; let mut ws = socket.write_stream.lock().await;
let _ = ws ws.send(WsMessage::Close(Some(WsCloseFrame {
.send(WsMessage::Close(Some(WsCloseFrame {
code: match code { code: match code {
Some(code) if (1000..=4999).contains(&code) => WsCloseCode::from(code), Some(code) if (1000..=4999).contains(&code) => WsCloseCode::from(code),
Some(code) => { Some(code) => {
@ -167,7 +166,8 @@ where
}, },
reason: "".into(), reason: "".into(),
}))) })))
.await; .await
.map_err(LuaError::external)?;
let res = ws.close(); let res = ws.close();
res.await.map_err(LuaError::external) res.await.map_err(LuaError::external)