1
0
mirror of https://github.com/actix/examples synced 2024-11-30 17:14:35 +01:00

Fix client. (#400)

This commit is contained in:
Eden Yefet 2021-01-17 04:55:00 +02:00 committed by GitHub
parent 91865b3a2a
commit c36d7371a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,7 +74,7 @@ impl Actor for ChatClient {
impl ChatClient { impl ChatClient {
fn hb(&self, ctx: &mut Context<Self>) { fn hb(&self, ctx: &mut Context<Self>) {
ctx.run_later(Duration::new(1, 0), |act, ctx| { ctx.run_later(Duration::new(1, 0), |act, ctx| {
act.0.write(Message::Ping(Bytes::from_static(b""))).unwrap(); act.0.write(Message::Ping(Bytes::from_static(b"")));
act.hb(ctx); act.hb(ctx);
// client should also check for a timeout here, similar to the // client should also check for a timeout here, similar to the
@ -88,7 +88,7 @@ impl Handler<ClientCommand> for ChatClient {
type Result = (); type Result = ();
fn handle(&mut self, msg: ClientCommand, _ctx: &mut Context<Self>) { fn handle(&mut self, msg: ClientCommand, _ctx: &mut Context<Self>) {
self.0.write(Message::Text(msg.0)).unwrap(); self.0.write(Message::Text(msg.0));
} }
} }