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 from, does not receive the published message. The event’s message must be a map serializable as JSON

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 %Phoenix.Socket{}

terminate(socket)

Terminates socket connection, including all multiplexed channels

unsubscribe(pid, channel, topic)

Unsubscribes socket from given channel topic Returns %Phoenix.Socket{}

Functions

broadcast(socket, event, message)
broadcast(channel, topic, event, message)

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_from(socket, event, message)

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
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 %Phoenix.Socket{}

terminate(socket)

Terminates socket connection, including all multiplexed channels

unsubscribe(pid, channel, topic)

Unsubscribes socket from given channel topic Returns %Phoenix.Socket{}

Callbacks

join/3

Specs: