MCPcopy Create free account
hub / github.com/miguelgrinberg/python-socketio / send

Method send

src/socketio/async_server.py:184–225  ·  view source on GitHub ↗

Send a message to one or more connected clients. 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``, ``li

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

Source from the content-addressed store, hash-verified

182 ignore_queue=ignore_queue)
183
184 async def send(self, data, to=None, room=None, skip_sid=None,
185 namespace=None, callback=None, ignore_queue=False):
186 """Send a message to one or more connected clients.
187
188 This function emits an event with the name ``'message'``. Use
189 :func:`emit` to issue custom event names.
190
191 :param data: The data to send to the client or clients. Data can be of
192 type ``str``, ``bytes``, ``list`` or ``dict``. To send
193 multiple arguments, use a tuple where each element is of
194 one of the types indicated above.
195 :param to: The recipient of the message. This can be set to the
196 session ID of a client to address only that client, to any
197 any custom room created by the application to address all
198 the clients in that room, or to a list of custom room
199 names. If this argument is omitted the event is broadcasted
200 to all connected clients.
201 :param room: Alias for the ``to`` parameter.
202 :param skip_sid: The session ID of a client to skip when broadcasting
203 to a room or to all clients. This can be used to
204 prevent a message from being sent to the sender.
205 :param namespace: The Socket.IO namespace for the event. If this
206 argument is omitted the event is emitted to the
207 default namespace.
208 :param callback: If given, this function will be called to acknowledge
209 the client has received the message. The arguments
210 that will be passed to the function are those provided
211 by the client. Callback functions can only be used
212 when addressing an individual client.
213 :param ignore_queue: Only used when a message queue is configured. If
214 set to ``True``, the event is emitted to the
215 clients directly, without going through the queue.
216 This is more efficient, but only works when a
217 single server process is used. It is recommended
218 to always leave this parameter with its default
219 value of ``False``.
220
221 Note: this method is a coroutine.
222 """
223 await self.emit('message', data=data, to=to, room=room,
224 skip_sid=skip_sid, namespace=namespace,
225 callback=callback, ignore_queue=ignore_queue)
226
227 async def call(self, event, data=None, to=None, sid=None, namespace=None,
228 timeout=60, ignore_queue=False):

Callers 2

test_sendMethod · 0.95
_send_packetMethod · 0.45

Calls 1

emitMethod · 0.95

Tested by 1

test_sendMethod · 0.76