shutdown websocket if the server disconnected, level up the default log print
This commit is contained in:
parent
694b462f60
commit
f21a180053
@ -111,6 +111,9 @@ impl StreamHandler<Result<Bytes, io::Error>> for Agent {
|
||||
}
|
||||
Err(err) => {
|
||||
error!("error: {:?}", err);
|
||||
if self.ws_addr.is_some() {
|
||||
self.ws_addr.as_ref().unwrap().do_send(ws::WsMsg::Close);
|
||||
}
|
||||
ctx.address().do_send(AgentMsg::Shutdown);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ use super::agent::*;
|
||||
#[rtype(result = "()")]
|
||||
pub enum WsMsg {
|
||||
SendToClient(Bytes),
|
||||
Close,
|
||||
}
|
||||
|
||||
/// Define Websocket actor
|
||||
@ -41,6 +42,9 @@ impl Handler<WsMsg> for WsSession {
|
||||
WsMsg::SendToClient(data) => {
|
||||
ctx.binary(data);
|
||||
}
|
||||
WsMsg::Close => {
|
||||
ctx.stop();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ impl Default for AppData {
|
||||
fn setup_logger() {
|
||||
let logger = femme::pretty::Logger::new();
|
||||
async_log::Logger::wrap(logger, || 12)
|
||||
.start(log::LevelFilter::Trace)
|
||||
.start(log::LevelFilter::Warn)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user