Struct trillium_channels::ChannelConn[][src]

pub struct ChannelConn<'a> { /* fields omitted */ }
Expand description

A ChannelConn is a wrapper around a WebSocketConn that also contains a ChannelClient

It that provides convenient access to functions from the ChannelClient held in the WebSocketConn’s StateSet, and dereferences to the WebSocketConn for other functionality.

Implementations

Borrow the channel client

Borrow the websocket conn

Send a ChannelEvent to all connected clients. Note that these messages will only reach clients that subscribe to the event’s topic.

Send a ChannelEvent to this specific client. Note that this message will only be received if the client subscribes to the event’s topic.

Send an ok reply in reference to the provided ChannelEvent with the provided response payload.

Note that this sets the event as "phx_reply" and the payload as {"status": "ok", "response": response }, as well as setting the reference field.

Send an error reply in reference to the provided ChannelEvent with the provided response payload.

Note that this sets the event as "phx_error" as well as setting the reference field.

Join a topic, sending an ok reply with the provided optional value. This sends an ok reply to the client as well as adding the topic to the client’s subscriptions.

Leave a topic as requested by the provided channel event, including the optional payload. This sends an ok reply to the client as well as removing the channel from the client’s subscriptions.

Methods from Deref<Target = WebSocketConn>

send a [Message::Text] variant

send a [Message::Binary] variant

send a [Message::Text] that contains json note that json messages are not actually part of the websocket specification

Sends a [Message] to the client

retrieve a clone of the server’s [Stopper]

close the websocket connection gracefully

retrieve the request headers for this conn

retrieves the path part of the request url, up to and excluding any query component

Retrieves the query component of the path, excluding ?. Returns an empty string if there is no query component.

retrieve the request method for this conn

retrieve state from the state set that has been accumulated by trillium handlers run on the trillium::Conn before it became a websocket. see trillium::Conn::state for more information

retrieve a mutable borrow of the state from the state set

set state on this connection

take some type T out of the state set that has been accumulated by trillium handlers run on the trillium::Conn before it became a websocket. see trillium::Conn::take_state for more information

take the inbound Message stream from this conn

borrow the inbound Message stream from this conn

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.