InvergeDocs
PythonAPI reference

Realtime

Realtime rooms — server-side emit and room management.

// access
client.realtime

Realtime rooms — server-side emit and room management.

Emitting broadcasts to every client currently joined to the room. Rooms are environment-scoped: a client joined with a key from another environment will never see your emit, which is the usual cause of "the message just doesn't arrive".

To receive events in Python (a worker that reacts to room traffic), use nexus.RealtimeSocket — it needs python-socketio.

Realtime

class

client.realtime

Extends Resource.

View source

emit()

method
def emit(room, events=(), payload=None) -> Dict[str, Any]

Emit one or more named events to a room.

client.realtime.emit("orders:42", "status", {"state": "shipped"})
client.realtime.emit("orders:42", ["status", "updated"], {"state": "shipped"})
client.realtime.emit(RoomMessage("orders:42", "status", {"state": "shipped"}))

Returns the ack: {ok, room, related, events, recipients}.

Parameters

Prop

Type

Returns Dict[str, Any]

View source

broadcast()

method
def broadcast(messages) -> Dict[str, Any]

Send to many rooms, each with its own events/payload, in one request.

Parameters

Prop

Type

Returns Dict[str, Any]

View source

emit_to_rooms()

method
def emit_to_rooms(rooms, events, payload=None) -> Dict[str, Any]

The same event(s) and payload to several rooms, in one request.

Parameters

Prop

Type

Returns Dict[str, Any]

View source

register_room()

method
def register_room(name, type=None) -> Dict[str, Any]

Create a room up front (they are also auto-created on join/emit).

Parameters

Prop

Type

Returns Dict[str, Any]

View source

rooms()

method
def rooms() -> List[Any]

The environment's registered rooms.

Returns List[Any]

View source

delete_room()

method
def delete_room(room_id) -> None

Parameters

Prop

Type

View source method
def link(room_id, related_id) -> None

Link two rooms so an emit to one also reaches the other.

Parameters

Prop

Type

View source method
def unlink(room_id, related_id) -> None

Parameters

Prop

Type

View source method
def related(name) -> Any

Rooms linked to this one.

Parameters

Prop

Type

Returns Any

View source

schema()

method
def schema(room_id) -> Dict[str, Any]

The room's JSON Schema, if one is set.

Parameters

Prop

Type

Returns Dict[str, Any]

View source

set_schema()

method
def set_schema(room_id, schema) -> Dict[str, Any]

Attach a JSON Schema that payloads to this room must satisfy.

Parameters

Prop

Type

Returns Dict[str, Any]

View source

enable_schema()

method
def enable_schema(room_id, enabled=True) -> Dict[str, Any]

Turn schema validation on or off.

Parameters

Prop

Type

Returns Dict[str, Any]

View source

clear_schema()

method
def clear_schema(room_id) -> None

Parameters

Prop

Type

View source

On this page