Browse Source

Document the user of tuples when emitting

pull/1118/head
Miguel Grinberg 5 years ago
parent
commit
3ac3437af7
No known key found for this signature in database GPG Key ID: 36848B262DF5F06C
  1. 31
      socketio/asyncio_client.py
  2. 15
      socketio/asyncio_server.py
  3. 31
      socketio/client.py
  4. 15
      socketio/server.py

31
socketio/asyncio_client.py

@ -139,17 +139,17 @@ class AsyncClient(client.Client):
: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
@ -190,17 +190,17 @@ class AsyncClient(client.Client):
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.
"""
@ -213,9 +213,10 @@ class AsyncClient(client.Client):
: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.

15
socketio/asyncio_server.py

@ -91,8 +91,9 @@ class AsyncServer(server.Server):
``'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
@ -142,8 +143,9 @@ class AsyncServer(server.Server):
: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
@ -183,8 +185,9 @@ class AsyncServer(server.Server):
``'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

31
socketio/client.py

@ -307,17 +307,17 @@ class Client(object):
: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
@ -356,17 +356,17 @@ class Client(object):
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)
@ -377,9 +377,10 @@ class Client(object):
: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.

15
socketio/server.py

@ -253,8 +253,9 @@ class Server(object):
``'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
@ -302,8 +303,9 @@ class Server(object):
: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
@ -341,8 +343,9 @@ class Server(object):
``'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

Loading…
Cancel
Save