Skip to content

Channel#

realtime.channel.Channel #

Channel is an abstraction for a topic listener for an existing socket connection. Each Channel has its own topic and a list of event-callbacks that responds to messages. Should only be instantiated through connection.Socket().set_chanel(topic) Topic-Channel has a 1-many relationship.

__init__(self, socket, topic, params={}) special #

Parameters:

Name Type Description Default
socket Socket

Socket object

required
topic str

Topic to subcribe to on the realtime server

required
params dict {}

join(self) async #

Attempt to join Phoenix Realtime server for a certain topic.

on(self, event, callback) #

Parameters:

Name Type Description Default
event str

A specific event will have a specific callback

required
callback Callable[[Any], Any]

Callback that takes msg payload as its first argument

required

Returns:

Type Description
Channel

Channel

off(self, event) #

Stop listening to a particular event.

Parameters:

Name Type Description Default
event str

event to stop responding to

required
Back to top