mirror of
https://github.com/dnaka91/obws
synced 2024-11-13 19:12:03 +00:00
Fix handling of the close event
This commit is contained in:
parent
98983b472d
commit
0db0b0058b
@ -206,19 +206,15 @@ impl Client {
|
||||
|
||||
let handle = tokio::spawn(async move {
|
||||
while let Some(Ok(msg)) = read.next().await {
|
||||
if msg.is_close() {
|
||||
#[cfg(feature = "events")]
|
||||
events_tx.send(Event::ServerStopping).ok();
|
||||
continue;
|
||||
}
|
||||
|
||||
trace!("{}", msg);
|
||||
let res: Result<(), InnerError> = async {
|
||||
let text = msg.into_text().map_err(InnerError::IntoText)?;
|
||||
let text = if text == "Server stopping" {
|
||||
debug!("Websocket server is stopping");
|
||||
let event = serde_json::json! {{
|
||||
"messageType": "Event",
|
||||
"eventType": "ServerStopping"
|
||||
}};
|
||||
event.to_string()
|
||||
} else {
|
||||
text
|
||||
};
|
||||
|
||||
let message = serde_json::from_str::<ServerMessage>(&text)
|
||||
.map_err(InnerError::DeserializeMessage)?;
|
||||
|
Loading…
Reference in New Issue
Block a user