[][src]Struct actix_web_actors::ws::WebsocketContext

pub struct WebsocketContext<A> where
    A: Actor<Context = WebsocketContext<A>>, 
{ /* fields omitted */ }

Execution context for WebSockets actors

Methods

impl<A> WebsocketContext<A> where
    A: Actor<Context = Self>, 
[src]

pub fn create<S>(
    actor: A,
    stream: S
) -> impl Stream<Item = Bytes, Error = Error> where
    A: StreamHandler<Message, ProtocolError>,
    S: Stream<Item = Bytes, Error = PayloadError> + 'static, 
[src]

Create a new Websocket context from a request and an actor

pub fn with_factory<S, F>(
    stream: S,
    f: F
) -> impl Stream<Item = Bytes, Error = Error> where
    F: FnOnce(&mut Self) -> A + 'static,
    A: StreamHandler<Message, ProtocolError>,
    S: Stream<Item = Bytes, Error = PayloadError> + 'static, 
[src]

Create a new Websocket context

impl<A> WebsocketContext<A> where
    A: Actor<Context = Self>, 
[src]

pub fn write_raw(&mut self, msg: Message)[src]

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 text<T: Into<String>>(&mut self, text: T)[src]

Send text frame

pub fn binary<B: Into<Bytes>>(&mut self, data: B)[src]

Send binary frame

pub fn ping(&mut self, message: &str)[src]

Send ping frame

pub fn pong(&mut self, message: &str)[src]

Send pong frame

pub fn close(&mut self, reason: Option<CloseReason>)[src]

Send close frame

pub fn handle(&self) -> SpawnHandle[src]

Handle of the running future

SpawnHandle is the handle returned by AsyncContext::spawn() method.

pub fn set_mailbox_capacity(&mut self, cap: usize)[src]

Set mailbox capacity

By default mailbox capacity is 16 messages.

Trait Implementations

impl<A> ActorContext for WebsocketContext<A> where
    A: Actor<Context = Self>, 
[src]

impl<A> AsyncContext<A> for WebsocketContext<A> where
    A: Actor<Context = Self>, 
[src]

fn waiting(&self) -> bool[src]

Checks if the 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, 
[src]

Registers a stream with the context. 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
[src]

Registers a stream with the context, ignoring errors. Read more

fn notify<M>(&mut self, msg: M) where
    A: Handler<M>,
    M: Message + 'static, 
[src]

Sends the message msg to self. This bypasses the mailbox capacity, and will always queue the message. If the actor is in the stopped state, an error will be raised. Read more

fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandle where
    A: Handler<M>,
    M: Message + 'static, 
[src]

Sends the message msg to self after a specified period of time. Read more

fn run_later<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
    F: FnOnce(&mut A, &mut <A as Actor>::Context) + 'static, 
[src]

Executes a closure after a specified period of time. Read more

fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
    F: FnMut(&mut A, &mut <A as Actor>::Context) + 'static, 
[src]

Spawns a job to execute the given closure periodically, at a specified fixed interval. Read more

impl<A> AsyncContextParts<A> for WebsocketContext<A> where
    A: Actor<Context = Self>, 
[src]

impl<A, M> ToEnvelope<A, M> for WebsocketContext<A> where
    A: Actor<Context = WebsocketContext<A>> + Handler<M>,
    M: ActixMessage + Send + 'static,
    M::Result: Send
[src]

Auto Trait Implementations

impl<A> !Send for WebsocketContext<A>

impl<A> !Sync for WebsocketContext<A>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Erased for T