[−][src]Struct actix_web::ws::WebsocketContext
Execution context for WebSockets
actors
Methods
impl<A, S: 'static> WebsocketContext<A, S> where
A: Actor<Context = Self>,
[src]
impl<A, S: 'static> WebsocketContext<A, S> where
A: Actor<Context = Self>,
pub fn create<P>(req: HttpRequest<S>, actor: A, stream: WsStream<P>) -> Body where
A: StreamHandler<Message, ProtocolError>,
P: Stream<Item = Bytes, Error = PayloadError> + 'static,
[src]
pub fn create<P>(req: HttpRequest<S>, actor: A, stream: WsStream<P>) -> Body where
A: StreamHandler<Message, ProtocolError>,
P: Stream<Item = Bytes, Error = PayloadError> + 'static,
Create a new Websocket context from a request and an actor
pub fn with_factory<F>(req: HttpRequest<S>, f: F) -> Body where
F: FnOnce(&mut Self) -> A + 'static,
[src]
pub fn with_factory<F>(req: HttpRequest<S>, f: F) -> Body where
F: FnOnce(&mut Self) -> A + 'static,
Create a new Websocket context
impl<A, S> WebsocketContext<A, S> where
A: Actor<Context = Self>,
[src]
impl<A, S> WebsocketContext<A, S> where
A: Actor<Context = Self>,
pub fn write_raw(&mut self, data: FramedMessage)
[src]
pub fn write_raw(&mut self, data: FramedMessage)
Write payload
This is a low-level function that accepts framed messages that should
be created using Frame::message()
. If you want to send text or binary
data you should prefer the text()
or binary()
convenience functions
that handle the framing for you.
pub fn state(&self) -> &S
[src]
pub fn state(&self) -> &S
Shared application state
pub fn request(&mut self) -> &mut HttpRequest<S>
[src]
pub fn request(&mut self) -> &mut HttpRequest<S>
Incoming request
pub fn drain(&mut self) -> Drain<A>
[src]
pub fn drain(&mut self) -> Drain<A>
Returns drain future
pub fn text<T: Into<Binary>>(&mut self, text: T)
[src]
pub fn text<T: Into<Binary>>(&mut self, text: T)
Send text frame
pub fn binary<B: Into<Binary>>(&mut self, data: B)
[src]
pub fn binary<B: Into<Binary>>(&mut self, data: B)
Send binary frame
pub fn ping(&mut self, message: &str)
[src]
pub fn ping(&mut self, message: &str)
Send ping frame
pub fn pong(&mut self, message: &str)
[src]
pub fn pong(&mut self, message: &str)
Send pong frame
pub fn close(&mut self, reason: Option<CloseReason>)
[src]
pub fn close(&mut self, reason: Option<CloseReason>)
Send close frame
pub fn connected(&self) -> bool
[src]
pub fn connected(&self) -> bool
Check if connection still open
pub fn handle(&self) -> SpawnHandle
[src]
pub fn handle(&self) -> SpawnHandle
Handle of the running future
SpawnHandle is the handle returned by AsyncContext::spawn()
method.
Trait Implementations
impl<A, S> WsWriter for WebsocketContext<A, S> where
A: Actor<Context = Self>,
S: 'static,
[src]
impl<A, S> WsWriter for WebsocketContext<A, S> where
A: Actor<Context = Self>,
S: 'static,
fn send_text<T: Into<Binary>>(&mut self, text: T)
[src]
fn send_text<T: Into<Binary>>(&mut self, text: T)
Send text frame
fn send_binary<B: Into<Binary>>(&mut self, data: B)
[src]
fn send_binary<B: Into<Binary>>(&mut self, data: B)
Send binary frame
fn send_ping(&mut self, message: &str)
[src]
fn send_ping(&mut self, message: &str)
Send ping frame
fn send_pong(&mut self, message: &str)
[src]
fn send_pong(&mut self, message: &str)
Send pong frame
fn send_close(&mut self, reason: Option<CloseReason>)
[src]
fn send_close(&mut self, reason: Option<CloseReason>)
Send close frame
impl<A, S> ActorContext for WebsocketContext<A, S> where
A: Actor<Context = Self>,
[src]
impl<A, S> ActorContext for WebsocketContext<A, S> where
A: Actor<Context = Self>,
fn stop(&mut self)
[src]
fn stop(&mut self)
Immediately stop processing incoming messages and switch to a stopping
state Read more
fn terminate(&mut self)
[src]
fn terminate(&mut self)
Terminate actor execution
fn state(&self) -> ActorState
[src]
fn state(&self) -> ActorState
Actor execution state
impl<A, S> AsyncContext<A> for WebsocketContext<A, S> where
A: Actor<Context = Self>,
[src]
impl<A, S> AsyncContext<A> for WebsocketContext<A, S> where
A: Actor<Context = Self>,
fn spawn<F>(&mut self, fut: F) -> SpawnHandle where
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
[src]
fn spawn<F>(&mut self, fut: F) -> SpawnHandle where
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
Spawn async future into context. Returns handle of the item, could be used for cancelling execution. Read more
fn wait<F>(&mut self, fut: F) where
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
[src]
fn wait<F>(&mut self, fut: F) where
F: ActorFuture<Item = (), Error = (), Actor = A> + 'static,
Spawn future into the context. Stop processing any of incoming events until this future resolves. Read more
fn cancel_future(&mut self, handle: SpawnHandle) -> bool
[src]
fn cancel_future(&mut self, handle: SpawnHandle) -> bool
Cancel future. handle is a value returned by spawn
method.
fn address(&self) -> Addr<A>
[src]
fn address(&self) -> Addr<A>
Return Address
of the context
fn waiting(&self) -> bool
fn waiting(&self) -> bool
Check if context is paused (waiting for future completion or stopping)
fn add_stream<S>(&mut self, fut: S) -> SpawnHandle where
A: StreamHandler<<S as Stream>::Item, <S as Stream>::Error>,
S: Stream + 'static,
fn add_stream<S>(&mut self, fut: S) -> SpawnHandle where
A: StreamHandler<<S as Stream>::Item, <S as Stream>::Error>,
S: Stream + 'static,
This method register stream to an actor context and allows to handle Stream
in similar way as normal actor messages. Read more
fn add_message_stream<S>(&mut self, fut: S) where
A: Handler<<S as Stream>::Item>,
S: Stream<Error = ()> + 'static,
<S as Stream>::Item: Message,
fn add_message_stream<S>(&mut self, fut: S) where
A: Handler<<S as Stream>::Item>,
S: Stream<Error = ()> + 'static,
<S as Stream>::Item: Message,
This method is similar to add_stream
but it skips stream errors. Read more
fn notify<M>(&mut self, msg: M) where
A: Handler<M>,
M: Message + 'static,
fn notify<M>(&mut self, msg: M) where
A: Handler<M>,
M: Message + 'static,
Send message msg
to self.
fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandle where
A: Handler<M>,
M: Message + 'static,
fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandle where
A: Handler<M>,
M: Message + 'static,
Send message msg
to self after specified period of time. Returns spawn handle which could be used for cancellation. Notification get cancelled if context's stop method get called. Read more
fn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
F: FnOnce(&mut A, &mut <A as Actor>::Context) + 'static,
fn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
F: FnOnce(&mut A, &mut <A as Actor>::Context) + 'static,
Execute closure after specified period of time within same Actor and Context. Execution get cancelled if context's stop method get called. Read more
fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
F: FnMut(&mut A, &mut <A as Actor>::Context) + 'static,
fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
F: FnMut(&mut A, &mut <A as Actor>::Context) + 'static,
Spawns a job to execute the given closure periodically, at a specified fixed interval Read more
impl<A, M, S> ToEnvelope<A, M> for WebsocketContext<A, S> where
A: Actor<Context = WebsocketContext<A, S>> + Handler<M>,
M: ActixMessage + Send + 'static,
M::Result: Send,
[src]
impl<A, M, S> ToEnvelope<A, M> for WebsocketContext<A, S> where
A: Actor<Context = WebsocketContext<A, S>> + Handler<M>,
M: ActixMessage + Send + 'static,
M::Result: Send,
fn pack(msg: M, tx: Option<Sender<M::Result>>) -> Envelope<A>
[src]
fn pack(msg: M, tx: Option<Sender<M::Result>>) -> Envelope<A>
Pack message into suitable envelope
impl<A, S> AsyncContextParts<A> for WebsocketContext<A, S> where
A: Actor<Context = Self>,
[src]
impl<A, S> AsyncContextParts<A> for WebsocketContext<A, S> where
A: Actor<Context = Self>,
fn parts(&mut self) -> &mut ContextParts<A>
[src]
fn parts(&mut self) -> &mut ContextParts<A>
Auto Trait Implementations
impl<A, S = ()> !Send for WebsocketContext<A, S>
impl<A, S = ()> !Send for WebsocketContext<A, S>
impl<A, S = ()> !Sync for WebsocketContext<A, S>
impl<A, S = ()> !Sync for WebsocketContext<A, S>
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
impl<T> Erased for T