Add event when no more messages, indicating that the server has stopped

This commit is contained in:
Brian Spit 2021-03-07 06:45:57 +01:00
parent bece4b3ac0
commit 34a37d0630
2 changed files with 13 additions and 1 deletions

View file

@ -27,7 +27,7 @@ use tokio::{
use tokio_tungstenite::{tungstenite::Message, MaybeTlsStream, WebSocketStream};
#[cfg(feature = "events")]
use crate::events::Event;
use crate::events::{Event, EventType};
use crate::{
requests::{Request, RequestType},
responses::{AuthRequired, Response},
@ -208,6 +208,16 @@ impl Client {
error!("failed handling message: {:?}", e);
}
}
#[cfg(feature = "events")]
{
let event = Event {
stream_timecode: None,
rec_timecode: None,
ty: EventType::ServerStopped,
};
events_tx.send(event).ok();
}
});
let write = Mutex::new(write);

View file

@ -577,6 +577,8 @@ pub enum EventType {
},
/// WebSocket server is stopping.
ServerStopping,
/// WebSocket server has stopped.
ServerStopped,
/// Fallback value for any unknown event type.
#[serde(other)]
Unknown,