From f4873fcdee2acb1189cbda04bdd67866aba0d14b Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 23 Jan 2018 15:35:39 -0800 Subject: [PATCH] stop websocket context --- src/context.rs | 9 +++++++++ src/ws/context.rs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/context.rs b/src/context.rs index 99433d29d..5187dd0b9 100644 --- a/src/context.rs +++ b/src/context.rs @@ -27,6 +27,15 @@ pub enum Frame { Drain(oneshot::Sender<()>), } +impl Frame { + pub fn len(&self) -> usize { + match *self { + Frame::Chunk(Some(ref bin)) => bin.len(), + _ => 0, + } + } +} + /// Http actor execution context pub struct HttpContext where A: Actor>, { diff --git a/src/ws/context.rs b/src/ws/context.rs index 2fa3c7647..33f6f6964 100644 --- a/src/ws/context.rs +++ b/src/ws/context.rs @@ -58,7 +58,8 @@ impl AsyncContext for WebsocketContext where A: Actor bool { - self.inner.wating() + self.inner.wating() || self.inner.start() == ActorState::Stopping || + self.inner.start() == ActorState::Stopped } fn cancel_future(&mut self, handle: SpawnHandle) -> bool {