Connection#
realtime.connection.Socket
#
__init__(self, url, params={}, hb_interval=5)
special
#
Socket
is the abstraction for an actual socket connection that receives and 'reroutes' Message
according to its topic
and event
.
Socket-Channel has a 1-many relationship.
Socket-Topic has a 1-many relationship.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str |
Websocket URL of the Realtime server. starts with |
required |
params |
dict |
Optional parameters for connection. |
{} |
hb_interval |
int |
WS connection is kept alive by sending a heartbeat message every few seconds. |
5 |
connect(self)
async
#
Connect to the realtime server.
set_channel(self, topic)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
topic |
str |
Initializes a channel and creates a two-way association with the socket |
required |
Returns:
Type | Description |
---|---|
Channel |
listen(self)
async
#
An infinite loop that keeps listening. This method should be called last.
summary(self)
#
Gets the list of sockets and events being listened for.