Struct actix_web_actors::ws::WebsocketContext [−][src]
pub struct WebsocketContext<A> where
A: Actor<Context = WebsocketContext<A>>, { /* fields omitted */ }
Expand description
Execution context for WebSockets
actors
Implementations
pub fn create<S>(
actor: A,
stream: S
) -> impl Stream<Item = Result<Bytes, Error>> where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
pub fn create<S>(
actor: A,
stream: S
) -> impl Stream<Item = Result<Bytes, Error>> where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
Create a new Websocket context from a request and an actor.
pub fn create_with_addr<S>(
actor: A,
stream: S
) -> (Addr<A>, impl Stream<Item = Result<Bytes, Error>>) where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
pub fn create_with_addr<S>(
actor: A,
stream: S
) -> (Addr<A>, impl Stream<Item = Result<Bytes, Error>>) where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
Create a new Websocket context from a request and an actor.
Returns a pair, where the first item is an addr for the created actor, and the second item
is a stream intended to be set as part of the response
via HttpResponseBuilder::streaming()
.
pub fn with_codec<S>(
actor: A,
stream: S,
codec: Codec
) -> impl Stream<Item = Result<Bytes, Error>> where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
pub fn with_codec<S>(
actor: A,
stream: S,
codec: Codec
) -> impl Stream<Item = Result<Bytes, Error>> where
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
Create a new Websocket context from a request, an actor, and a codec
pub fn with_factory<S, F>(
stream: S,
f: F
) -> impl Stream<Item = Result<Bytes, Error>> where
F: FnOnce(&mut Self) -> A + 'static,
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
pub fn with_factory<S, F>(
stream: S,
f: F
) -> impl Stream<Item = Result<Bytes, Error>> where
F: FnOnce(&mut Self) -> A + 'static,
A: StreamHandler<Result<Message, ProtocolError>>,
S: Stream<Item = Result<Bytes, PayloadError>> + 'static,
Create a new Websocket context
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.
Send text frame
Send close frame
Handle of the running future
SpawnHandle is the handle returned by AsyncContext::spawn()
method.
Set mailbox capacity
By default mailbox capacity is 16 messages.
Trait Implementations
Immediately stop processing incoming messages and switch to a
stopping
state. This only affects actors that are currently
running
. Future attempts to queue messages will fail. Read more
Terminate actor execution unconditionally. This sets the actor
into the stopped
state. This causes future attempts to queue
messages to fail. Read more
Retrieve the current Actor execution state.
Spawns a future into the context. Read more
Spawns a future into the context, waiting for it to resolve. Read more
Cancels a spawned future. Read more
Checks if the context is paused (waiting for future completion or stopping).
fn add_stream<S>(&mut self, fut: S) -> SpawnHandle where
S: 'static + Stream,
A: StreamHandler<<S as Stream>::Item>,
fn add_stream<S>(&mut self, fut: S) -> SpawnHandle where
S: 'static + Stream,
A: StreamHandler<<S as Stream>::Item>,
Registers a stream with the context. Read more
Registers a stream with the context, ignoring errors. Read more
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: 'static + Message,
fn notify_later<M>(&mut self, msg: M, after: Duration) -> SpawnHandle where
A: Handler<M>,
M: 'static + Message,
Sends the message msg
to self after a specified period of time. Read more
Executes a closure after a specified period of time. Read more
fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
F: 'static + FnMut(&mut A, &mut <A as Actor>::Context),
fn run_interval<F>(&mut self, dur: Duration, f: F) -> SpawnHandle where
F: 'static + FnMut(&mut A, &mut <A as Actor>::Context),
Spawns a job to execute the given closure periodically, at a specified fixed interval. Read more
impl<A, M> ToEnvelope<A, M> for WebsocketContext<A> where
A: Actor<Context = WebsocketContext<A>> + Handler<M>,
M: ActixMessage + Send + 'static,
M::Result: Send,
impl<A, M> ToEnvelope<A, M> for WebsocketContext<A> where
A: Actor<Context = WebsocketContext<A>> + Handler<M>,
M: ActixMessage + Send + 'static,
M::Result: Send,
Auto Trait Implementations
impl<A> !RefUnwindSafe for WebsocketContext<A>
impl<A> !Send for WebsocketContext<A>
impl<A> !Sync for WebsocketContext<A>
impl<A> Unpin for WebsocketContext<A>
impl<A> !UnwindSafe for WebsocketContext<A>
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more