Phoenix.Channel behaviour
Summary
broadcast(socket, event, message) | |
broadcast(channel, topic, event, message) | Broadcast event, serializable as JSON to topic namedspaced by channel |
broadcast_from(socket, event, message) | Broadcast event from pid, serializable as JSON to topic namedspaced by channel
The broadcasting socket |
broadcast_from(from, channel, topic, event, message) | |
hibernate(socket) | Hibernates socket connection |
reply(socket, event, message) | Sends Dict, JSON serializable message to socket |
subscribe(pid, channel, topic) | Subscribes socket to given channel topic
Returns |
terminate(socket) | Terminates socket connection, including all multiplexed channels |
unsubscribe(pid, channel, topic) | Unsubscribes socket from given channel topic
Returns |
Functions
Broadcast event, serializable as JSON to topic namedspaced by channel
Examples
iex> Channel.broadcast "rooms", "global", "new:message", %{id: 1, content: "hello"}
:ok
iex> Channel.broadcast socket, "new:message", %{id: 1, content: "hello"}
:ok
Broadcast event from pid, serializable as JSON to topic namedspaced by channel
The broadcasting socket from
, does not receive the published message.
The event’s message must be a map serializable as JSON.
Examples
iex> Channel.broadcast_from self, "rooms", "global", "new:message", %{id: 1, content: "hello"}
:ok
Subscribes socket to given channel topic
Returns %Phoenix.Socket{}
Callbacks
Specs:
- join(Phoenix.Socket.t, topic :: binary, auth_msg :: %{}) :: {:ok, Phoenix.Socket.t} | {:error, Phoenix.Socket.t, reason :: term}