Skip to content

Commit 3ac3437

Browse files
Document the user of tuples when emitting
1 parent 1fffa8c commit 3ac3437

File tree

4 files changed

+50
-42
lines changed

4 files changed

+50
-42
lines changed

socketio/asyncio_client.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,17 @@ async def emit(self, event, data=None, namespace=None, callback=None):
139139
:param event: The event name. It can be any string. The event names
140140
``'connect'``, ``'message'`` and ``'disconnect'`` are
141141
reserved and should not be used.
142-
:param data: The data to send to the client or clients. Data can be of
143-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
144-
``list`` or ``dict``, the data will be serialized as JSON.
142+
:param data: The data to send to the server. Data can be of
143+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
144+
multiple arguments, use a tuple where each element is of
145+
one of the types indicated above.
145146
:param namespace: The Socket.IO namespace for the event. If this
146147
argument is omitted the event is emitted to the
147148
default namespace.
148149
:param callback: If given, this function will be called to acknowledge
149-
the the client has received the message. The arguments
150+
the the server has received the message. The arguments
150151
that will be passed to the function are those provided
151-
by the client. Callback functions can only be used
152-
when addressing an individual client.
152+
by the server.
153153
154154
Note: this method is not designed to be used concurrently. If multiple
155155
tasks are emitting at the same time on the same client connection, then
@@ -190,17 +190,17 @@ async def send(self, data, namespace=None, callback=None):
190190
This function emits an event with the name ``'message'``. Use
191191
:func:`emit` to issue custom event names.
192192
193-
:param data: The data to send to the client or clients. Data can be of
194-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
195-
``list`` or ``dict``, the data will be serialized as JSON.
193+
:param data: The data to send to the server. Data can be of
194+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
195+
multiple arguments, use a tuple where each element is of
196+
one of the types indicated above.
196197
:param namespace: The Socket.IO namespace for the event. If this
197198
argument is omitted the event is emitted to the
198199
default namespace.
199200
:param callback: If given, this function will be called to acknowledge
200-
the the client has received the message. The arguments
201+
the the server has received the message. The arguments
201202
that will be passed to the function are those provided
202-
by the client. Callback functions can only be used
203-
when addressing an individual client.
203+
by the server.
204204
205205
Note: this method is a coroutine.
206206
"""
@@ -213,9 +213,10 @@ async def call(self, event, data=None, namespace=None, timeout=60):
213213
:param event: The event name. It can be any string. The event names
214214
``'connect'``, ``'message'`` and ``'disconnect'`` are
215215
reserved and should not be used.
216-
:param data: The data to send to the client or clients. Data can be of
217-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
218-
``list`` or ``dict``, the data will be serialized as JSON.
216+
:param data: The data to send to the server. Data can be of
217+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
218+
multiple arguments, use a tuple where each element is of
219+
one of the types indicated above.
219220
:param namespace: The Socket.IO namespace for the event. If this
220221
argument is omitted the event is emitted to the
221222
default namespace.

socketio/asyncio_server.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ async def emit(self, event, data=None, to=None, room=None, skip_sid=None,
9191
``'connect'``, ``'message'`` and ``'disconnect'`` are
9292
reserved and should not be used.
9393
:param data: The data to send to the client or clients. Data can be of
94-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
95-
``list`` or ``dict``, the data will be serialized as JSON.
94+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
95+
multiple arguments, use a tuple where each element is of
96+
one of the types indicated above.
9697
:param to: The recipient of the message. This can be set to the
9798
session ID of a client to address only that client, or to
9899
to any custom room created by the application to address all
@@ -142,8 +143,9 @@ async def send(self, data, to=None, room=None, skip_sid=None,
142143
:func:`emit` to issue custom event names.
143144
144145
:param data: The data to send to the client or clients. Data can be of
145-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
146-
``list`` or ``dict``, the data will be serialized as JSON.
146+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
147+
multiple arguments, use a tuple where each element is of
148+
one of the types indicated above.
147149
:param to: The recipient of the message. This can be set to the
148150
session ID of a client to address only that client, or to
149151
to any custom room created by the application to address all
@@ -183,8 +185,9 @@ async def call(self, event, data=None, to=None, sid=None, namespace=None,
183185
``'connect'``, ``'message'`` and ``'disconnect'`` are
184186
reserved and should not be used.
185187
:param data: The data to send to the client or clients. Data can be of
186-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
187-
``list`` or ``dict``, the data will be serialized as JSON.
188+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
189+
multiple arguments, use a tuple where each element is of
190+
one of the types indicated above.
188191
:param to: The session ID of the recipient client.
189192
:param sid: Alias for the ``to`` parameter.
190193
:param namespace: The Socket.IO namespace for the event. If this

socketio/client.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -307,17 +307,17 @@ def emit(self, event, data=None, namespace=None, callback=None):
307307
:param event: The event name. It can be any string. The event names
308308
``'connect'``, ``'message'`` and ``'disconnect'`` are
309309
reserved and should not be used.
310-
:param data: The data to send to the client or clients. Data can be of
311-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
312-
``list`` or ``dict``, the data will be serialized as JSON.
310+
:param data: The data to send to the server. Data can be of
311+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
312+
multiple arguments, use a tuple where each element is of
313+
one of the types indicated above.
313314
:param namespace: The Socket.IO namespace for the event. If this
314315
argument is omitted the event is emitted to the
315316
default namespace.
316317
:param callback: If given, this function will be called to acknowledge
317-
the the client has received the message. The arguments
318+
the the server has received the message. The arguments
318319
that will be passed to the function are those provided
319-
by the client. Callback functions can only be used
320-
when addressing an individual client.
320+
by the server.
321321
322322
Note: this method is not thread safe. If multiple threads are emitting
323323
at the same time on the same client connection, messages composed of
@@ -356,17 +356,17 @@ def send(self, data, namespace=None, callback=None):
356356
This function emits an event with the name ``'message'``. Use
357357
:func:`emit` to issue custom event names.
358358
359-
:param data: The data to send to the client or clients. Data can be of
360-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
361-
``list`` or ``dict``, the data will be serialized as JSON.
359+
:param data: The data to send to the server. Data can be of
360+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
361+
multiple arguments, use a tuple where each element is of
362+
one of the types indicated above.
362363
:param namespace: The Socket.IO namespace for the event. If this
363364
argument is omitted the event is emitted to the
364365
default namespace.
365366
:param callback: If given, this function will be called to acknowledge
366-
the the client has received the message. The arguments
367+
the the server has received the message. The arguments
367368
that will be passed to the function are those provided
368-
by the client. Callback functions can only be used
369-
when addressing an individual client.
369+
by the server.
370370
"""
371371
self.emit('message', data=data, namespace=namespace,
372372
callback=callback)
@@ -377,9 +377,10 @@ def call(self, event, data=None, namespace=None, timeout=60):
377377
:param event: The event name. It can be any string. The event names
378378
``'connect'``, ``'message'`` and ``'disconnect'`` are
379379
reserved and should not be used.
380-
:param data: The data to send to the client or clients. Data can be of
381-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
382-
``list`` or ``dict``, the data will be serialized as JSON.
380+
:param data: The data to send to the server. Data can be of
381+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
382+
multiple arguments, use a tuple where each element is of
383+
one of the types indicated above.
383384
:param namespace: The Socket.IO namespace for the event. If this
384385
argument is omitted the event is emitted to the
385386
default namespace.

socketio/server.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,9 @@ def emit(self, event, data=None, to=None, room=None, skip_sid=None,
253253
``'connect'``, ``'message'`` and ``'disconnect'`` are
254254
reserved and should not be used.
255255
:param data: The data to send to the client or clients. Data can be of
256-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
257-
``list`` or ``dict``, the data will be serialized as JSON.
256+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
257+
multiple arguments, use a tuple where each element is of
258+
one of the types indicated above.
258259
:param to: The recipient of the message. This can be set to the
259260
session ID of a client to address only that client, or to
260261
to any custom room created by the application to address all
@@ -302,8 +303,9 @@ def send(self, data, to=None, room=None, skip_sid=None, namespace=None,
302303
:func:`emit` to issue custom event names.
303304
304305
:param data: The data to send to the client or clients. Data can be of
305-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
306-
``list`` or ``dict``, the data will be serialized as JSON.
306+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
307+
multiple arguments, use a tuple where each element is of
308+
one of the types indicated above.
307309
:param to: The recipient of the message. This can be set to the
308310
session ID of a client to address only that client, or to
309311
to any custom room created by the application to address all
@@ -341,8 +343,9 @@ def call(self, event, data=None, to=None, sid=None, namespace=None,
341343
``'connect'``, ``'message'`` and ``'disconnect'`` are
342344
reserved and should not be used.
343345
:param data: The data to send to the client or clients. Data can be of
344-
type ``str``, ``bytes``, ``list`` or ``dict``. If a
345-
``list`` or ``dict``, the data will be serialized as JSON.
346+
type ``str``, ``bytes``, ``list`` or ``dict``. To send
347+
multiple arguments, use a tuple where each element is of
348+
one of the types indicated above.
346349
:param to: The session ID of the recipient client.
347350
:param sid: Alias for the ``to`` parameter.
348351
:param namespace: The Socket.IO namespace for the event. If this

0 commit comments

Comments
 (0)