Namespaces

class socketio.ClientNamespace(namespace=None)

Base class for client-side class-based namespaces.

A class-based namespace is a class that contains all the event handlers for a Socket.IO namespace. The event handlers are methods of the class with the prefix on_, such as on_connect, on_disconnect, on_message, on_json, and so on.

Parameters:

namespace – The Socket.IO namespace to be used with all the event handlers defined in this class. If this argument is omitted, the default namespace is used.

call(event, data=None, namespace=None, timeout=None)

Emit a custom event to the server and wait for the response.

The only difference with the socketio.Client.call() method is that when the namespace argument is not given the namespace associated with the class is used.

disconnect()

Disconnect from the server.

The only difference with the socketio.Client.disconnect() method is that when the namespace argument is not given the namespace associated with the class is used.

emit(event, data=None, namespace=None, callback=None)

Emit a custom event to the server.

The only difference with the socketio.Client.emit() method is that when the namespace argument is not given the namespace associated with the class is used.

send(data, room=None, namespace=None, callback=None)

Send a message to the server.

The only difference with the socketio.Client.send() method is that when the namespace argument is not given the namespace associated with the class is used.

trigger_event(event, *args)

Dispatch an event to the proper handler method.

In the most common usage, this method is not overloaded by subclasses, as it performs the routing of events to methods. However, this method can be overridden if special dispatching rules are needed, or if having a single method that catches all events is desired.

class socketio.Namespace(namespace=None)

Base class for server-side class-based namespaces.

A class-based namespace is a class that contains all the event handlers for a Socket.IO namespace. The event handlers are methods of the class with the prefix on_, such as on_connect, on_disconnect, on_message, on_json, and so on.

Parameters:

namespace – The Socket.IO namespace to be used with all the event handlers defined in this class. If this argument is omitted, the default namespace is used.

call(event, data=None, to=None, sid=None, namespace=None, timeout=None, ignore_queue=False)

Emit a custom event to a client and wait for the response.

The only difference with the socketio.Server.call() method is that when the namespace argument is not given the namespace associated with the class is used.

close_room(room, namespace=None)

Close a room.

The only difference with the socketio.Server.close_room() method is that when the namespace argument is not given the namespace associated with the class is used.

disconnect(sid, namespace=None)

Disconnect a client.

The only difference with the socketio.Server.disconnect() method is that when the namespace argument is not given the namespace associated with the class is used.

emit(event, data=None, to=None, room=None, skip_sid=None, namespace=None, callback=None, ignore_queue=False)

Emit a custom event to one or more connected clients.

The only difference with the socketio.Server.emit() method is that when the namespace argument is not given the namespace associated with the class is used.

enter_room(sid, room, namespace=None)

Enter a room.

The only difference with the socketio.Server.enter_room() method is that when the namespace argument is not given the namespace associated with the class is used.

get_session(sid, namespace=None)

Return the user session for a client.

The only difference with the socketio.Server.get_session() method is that when the namespace argument is not given the namespace associated with the class is used.

leave_room(sid, room, namespace=None)

Leave a room.

The only difference with the socketio.Server.leave_room() method is that when the namespace argument is not given the namespace associated with the class is used.

rooms(sid, namespace=None)

Return the rooms a client is in.

The only difference with the socketio.Server.rooms() method is that when the namespace argument is not given the namespace associated with the class is used.

save_session(sid, session, namespace=None)

Store the user session for a client.

The only difference with the socketio.Server.save_session() method is that when the namespace argument is not given the namespace associated with the class is used.

send(data, to=None, room=None, skip_sid=None, namespace=None, callback=None, ignore_queue=False)

Send a message to one or more connected clients.

The only difference with the socketio.Server.send() method is that when the namespace argument is not given the namespace associated with the class is used.

session(sid, namespace=None)

Return the user session for a client with context manager syntax.

The only difference with the socketio.Server.session() method is that when the namespace argument is not given the namespace associated with the class is used.

trigger_event(event, *args)

Dispatch an event to the proper handler method.

In the most common usage, this method is not overloaded by subclasses, as it performs the routing of events to methods. However, this method can be overridden if special dispatching rules are needed, or if having a single method that catches all events is desired.

class socketio.AsyncClientNamespace(namespace=None)

Base class for asyncio client-side class-based namespaces.

A class-based namespace is a class that contains all the event handlers for a Socket.IO namespace. The event handlers are methods of the class with the prefix on_, such as on_connect, on_disconnect, on_message, on_json, and so on. These can be regular functions or coroutines.

Parameters:

namespace – The Socket.IO namespace to be used with all the event handlers defined in this class. If this argument is omitted, the default namespace is used.

async call(event, data=None, namespace=None, timeout=None)

Emit a custom event to the server and wait for the response.

The only difference with the socketio.Client.call() method is that when the namespace argument is not given the namespace associated with the class is used.

async disconnect()

Disconnect a client.

The only difference with the socketio.Client.disconnect() method is that when the namespace argument is not given the namespace associated with the class is used.

Note: this method is a coroutine.

async emit(event, data=None, namespace=None, callback=None)

Emit a custom event to the server.

The only difference with the socketio.Client.emit() method is that when the namespace argument is not given the namespace associated with the class is used.

Note: this method is a coroutine.

async send(data, namespace=None, callback=None)

Send a message to the server.

The only difference with the socketio.Client.send() method is that when the namespace argument is not given the namespace associated with the class is used.

Note: this method is a coroutine.

async trigger_event(event, *args)

Dispatch an event to the proper handler method.

In the most common usage, this method is not overloaded by subclasses, as it performs the routing of events to methods. However, this method can be overridden if special dispatching rules are needed, or if having a single method that catches all events is desired.

Note: this method is a coroutine.

class socketio.AsyncNamespace(namespace=None)

Base class for asyncio server-side class-based namespaces.

A class-based namespace is a class that contains all the event handlers for a Socket.IO namespace. The event handlers are methods of the class with the prefix on_, such as on_connect, on_disconnect, on_message, on_json, and so on. These can be regular functions or coroutines.

Parameters:

namespace – The Socket.IO namespace to be used with all the event handlers defined in this class. If this argument is omitted, the default namespace is used.

async call(event, data=None, to=None, sid=None, namespace=None, timeout=None, ignore_queue=False)

Emit a custom event to a client and wait for the response.

The only difference with the socketio.Server.call() method is that when the namespace argument is not given the namespace associated with the class is used.

async close_room(room, namespace=None)

Close a room.

The only difference with the socketio.Server.close_room() method is that when the namespace argument is not given the namespace associated with the class is used.

Note: this method is a coroutine.

async disconnect(sid, namespace=None)

Disconnect a client.

The only difference with the socketio.Server.disconnect() method is that when the namespace argument is not given the namespace associated with the class is used.

Note: this method is a coroutine.

async emit(event, data=None, to=None, room=None, skip_sid=None, namespace=None, callback=None, ignore_queue=False)

Emit a custom event to one or more connected clients.

The only difference with the socketio.Server.emit() method is that when the namespace argument is not given the namespace associated with the class is used.

Note: this method is a coroutine.

async enter_room(sid, room, namespace=None)

Enter a room.

The only difference with the socketio.Server.enter_room() method is that when the namespace argument is not given the namespace associated with the class is used.

Note: this method is a coroutine.

async get_session(sid, namespace=None)

Return the user session for a client.

The only difference with the socketio.Server.get_session() method is that when the namespace argument is not given the namespace associated with the class is used.

Note: this method is a coroutine.

async leave_room(sid, room, namespace=None)

Leave a room.

The only difference with the socketio.Server.leave_room() method is that when the namespace argument is not given the namespace associated with the class is used.

Note: this method is a coroutine.

rooms(sid, namespace=None)

Return the rooms a client is in.

The only difference with the socketio.Server.rooms() method is that when the namespace argument is not given the namespace associated with the class is used.

async save_session(sid, session, namespace=None)

Store the user session for a client.

The only difference with the socketio.Server.save_session() method is that when the namespace argument is not given the namespace associated with the class is used.

Note: this method is a coroutine.

async send(data, to=None, room=None, skip_sid=None, namespace=None, callback=None, ignore_queue=False)

Send a message to one or more connected clients.

The only difference with the socketio.Server.send() method is that when the namespace argument is not given the namespace associated with the class is used.

Note: this method is a coroutine.

session(sid, namespace=None)

Return the user session for a client with context manager syntax.

The only difference with the socketio.Server.session() method is that when the namespace argument is not given the namespace associated with the class is used.

async trigger_event(event, *args)

Dispatch an event to the proper handler method.

In the most common usage, this method is not overloaded by subclasses, as it performs the routing of events to methods. However, this method can be overridden if special dispatching rules are needed, or if having a single method that catches all events is desired.

Note: this method is a coroutine.