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
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 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
type Target = WebSocketConn
type Target = WebSocketConn
The resulting type after dereferencing.