pub struct ChannelClient { /* private fields */ }
Expand description

Communicate with the connected client.

Note that although each client is unique and represents a specific websocket connection, the ChannelClient can be cloned and moved elsewhere if needed and any updates to the topic subscriptions will be kept synchronized across clones.

Implementations

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.

Use &() as the payload if no payload is needed.

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.

Use &() as the payload if no payload is needed.

Borrow this client’s subscriptions

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.