Skip to content

Commit

Permalink
Document the user of tuples when emitting
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Aug 13, 2020
1 parent 1fffa8c commit 3ac3437
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 42 deletions.
31 changes: 16 additions & 15 deletions socketio/asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ async def emit(self, event, data=None, namespace=None, callback=None):
:param event: The event name. It can be any string. The event names
``'connect'``, ``'message'`` and ``'disconnect'`` are
reserved and should not be used.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
:param data: The data to send to the server. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param namespace: The Socket.IO namespace for the event. If this
argument is omitted the event is emitted to the
default namespace.
:param callback: If given, this function will be called to acknowledge
the the client has received the message. The arguments
the the server has received the message. The arguments
that will be passed to the function are those provided
by the client. Callback functions can only be used
when addressing an individual client.
by the server.
Note: this method is not designed to be used concurrently. If multiple
tasks are emitting at the same time on the same client connection, then
Expand Down Expand Up @@ -190,17 +190,17 @@ async def send(self, data, namespace=None, callback=None):
This function emits an event with the name ``'message'``. Use
:func:`emit` to issue custom event names.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
:param data: The data to send to the server. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param namespace: The Socket.IO namespace for the event. If this
argument is omitted the event is emitted to the
default namespace.
:param callback: If given, this function will be called to acknowledge
the the client has received the message. The arguments
the the server has received the message. The arguments
that will be passed to the function are those provided
by the client. Callback functions can only be used
when addressing an individual client.
by the server.
Note: this method is a coroutine.
"""
Expand All @@ -213,9 +213,10 @@ async def call(self, event, data=None, namespace=None, timeout=60):
:param event: The event name. It can be any string. The event names
``'connect'``, ``'message'`` and ``'disconnect'`` are
reserved and should not be used.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
:param data: The data to send to the server. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param namespace: The Socket.IO namespace for the event. If this
argument is omitted the event is emitted to the
default namespace.
Expand Down
15 changes: 9 additions & 6 deletions socketio/asyncio_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ async def emit(self, event, data=None, to=None, room=None, skip_sid=None,
``'connect'``, ``'message'`` and ``'disconnect'`` are
reserved and should not be used.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param to: The recipient of the message. This can be set to the
session ID of a client to address only that client, or to
to any custom room created by the application to address all
Expand Down Expand Up @@ -142,8 +143,9 @@ async def send(self, data, to=None, room=None, skip_sid=None,
:func:`emit` to issue custom event names.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param to: The recipient of the message. This can be set to the
session ID of a client to address only that client, or to
to any custom room created by the application to address all
Expand Down Expand Up @@ -183,8 +185,9 @@ async def call(self, event, data=None, to=None, sid=None, namespace=None,
``'connect'``, ``'message'`` and ``'disconnect'`` are
reserved and should not be used.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param to: The session ID of the recipient client.
:param sid: Alias for the ``to`` parameter.
:param namespace: The Socket.IO namespace for the event. If this
Expand Down
31 changes: 16 additions & 15 deletions socketio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,17 @@ def emit(self, event, data=None, namespace=None, callback=None):
:param event: The event name. It can be any string. The event names
``'connect'``, ``'message'`` and ``'disconnect'`` are
reserved and should not be used.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
:param data: The data to send to the server. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param namespace: The Socket.IO namespace for the event. If this
argument is omitted the event is emitted to the
default namespace.
:param callback: If given, this function will be called to acknowledge
the the client has received the message. The arguments
the the server has received the message. The arguments
that will be passed to the function are those provided
by the client. Callback functions can only be used
when addressing an individual client.
by the server.
Note: this method is not thread safe. If multiple threads are emitting
at the same time on the same client connection, messages composed of
Expand Down Expand Up @@ -356,17 +356,17 @@ def send(self, data, namespace=None, callback=None):
This function emits an event with the name ``'message'``. Use
:func:`emit` to issue custom event names.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
:param data: The data to send to the server. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param namespace: The Socket.IO namespace for the event. If this
argument is omitted the event is emitted to the
default namespace.
:param callback: If given, this function will be called to acknowledge
the the client has received the message. The arguments
the the server has received the message. The arguments
that will be passed to the function are those provided
by the client. Callback functions can only be used
when addressing an individual client.
by the server.
"""
self.emit('message', data=data, namespace=namespace,
callback=callback)
Expand All @@ -377,9 +377,10 @@ def call(self, event, data=None, namespace=None, timeout=60):
:param event: The event name. It can be any string. The event names
``'connect'``, ``'message'`` and ``'disconnect'`` are
reserved and should not be used.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
:param data: The data to send to the server. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param namespace: The Socket.IO namespace for the event. If this
argument is omitted the event is emitted to the
default namespace.
Expand Down
15 changes: 9 additions & 6 deletions socketio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ def emit(self, event, data=None, to=None, room=None, skip_sid=None,
``'connect'``, ``'message'`` and ``'disconnect'`` are
reserved and should not be used.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param to: The recipient of the message. This can be set to the
session ID of a client to address only that client, or to
to any custom room created by the application to address all
Expand Down Expand Up @@ -302,8 +303,9 @@ def send(self, data, to=None, room=None, skip_sid=None, namespace=None,
:func:`emit` to issue custom event names.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param to: The recipient of the message. This can be set to the
session ID of a client to address only that client, or to
to any custom room created by the application to address all
Expand Down Expand Up @@ -341,8 +343,9 @@ def call(self, event, data=None, to=None, sid=None, namespace=None,
``'connect'``, ``'message'`` and ``'disconnect'`` are
reserved and should not be used.
:param data: The data to send to the client or clients. Data can be of
type ``str``, ``bytes``, ``list`` or ``dict``. If a
``list`` or ``dict``, the data will be serialized as JSON.
type ``str``, ``bytes``, ``list`` or ``dict``. To send
multiple arguments, use a tuple where each element is of
one of the types indicated above.
:param to: The session ID of the recipient client.
:param sid: Alias for the ``to`` parameter.
:param namespace: The Socket.IO namespace for the event. If this
Expand Down

0 comments on commit 3ac3437

Please sign in to comment.