Skip to content

Commit 8e73457

Browse files
authored
The usage of class-based namespace
There should be an additional `self` argument passed to each member function of custom Namespaces.
1 parent 36f8d35 commit 8e73457

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/index.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,13 @@ that belong to a namespace can be created as methods of a subclass of
293293
:class:`socketio.Namespace`::
294294

295295
class MyCustomNamespace(socketio.Namespace):
296-
def on_connect(sid, environ):
296+
def on_connect(self, sid, environ):
297297
pass
298298

299-
def on_disconnect(sid):
299+
def on_disconnect(self, sid):
300300
pass
301301

302-
def on_my_event(sid, data):
302+
def on_my_event(self, sid, data):
303303
self.emit('my_response', data)
304304

305305
sio.register_namespace(MyCustomNamespace('/test'))
@@ -309,13 +309,13 @@ For asyncio based severs, namespaces must inherit from
309309
methods or coroutines::
310310

311311
class MyCustomNamespace(socketio.AsyncNamespace):
312-
def on_connect(sid, environ):
312+
def on_connect(self, sid, environ):
313313
pass
314314

315-
def on_disconnect(sid):
315+
def on_disconnect(self, sid):
316316
pass
317317

318-
async def on_my_event(sid, data):
318+
async def on_my_event(self, sid, data):
319319
await self.emit('my_response', data)
320320

321321
sio.register_namespace(MyCustomNamespace('/test'))

0 commit comments

Comments
 (0)