Skip to content

Commit

Permalink
Accept skip_sid argument in emit() function (Fixes #1147)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Jan 7, 2020
1 parent 15ad45a commit c06e78e
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions flask_socketio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ def ping():
:param room: Send the message to all the users in the given room. If
this parameter is not included, the event is sent to
all connected users.
:param include_self: ``True`` to include the sender when broadcasting
or addressing a room, or ``False`` to send to
everyone but the sender.
:param skip_sid: The session id of a client to ignore when broadcasting
or addressing a room. This is typically set to the
originator of the message, so that everyone except
Expand Down Expand Up @@ -441,6 +444,9 @@ def send(self, data, json=False, namespace=None, room=None,
:param room: Send the message only to the users in the given room. If
this parameter is not included, the message is sent to
all connected users.
:param include_self: ``True`` to include the sender when broadcasting
or addressing a room, or ``False`` to send to
everyone but the sender.
:param skip_sid: The session id of a client to ignore when broadcasting
or addressing a room. This is typically set to the
originator of the message, so that everyone except
Expand Down Expand Up @@ -748,6 +754,11 @@ def handle_my_custom_event(json):
:param include_self: ``True`` to include the sender when broadcasting or
addressing a room, or ``False`` to send to everyone
but the sender.
:param skip_sid: The session id of a client to ignore when broadcasting
or addressing a room. This is typically set to the
originator of the message, so that everyone except
that client receive the message. To skip multiple sids
pass a list.
:param ignore_queue: Only used when a message queue is configured. If
set to ``True``, the event is emitted to the
clients directly, without going through the queue.
Expand All @@ -766,12 +777,13 @@ def handle_my_custom_event(json):
if room is None and not broadcast:
room = flask.request.sid
include_self = kwargs.get('include_self', True)
skip_sid = kwargs.get('skip_sid')
ignore_queue = kwargs.get('ignore_queue', False)

socketio = flask.current_app.extensions['socketio']
return socketio.emit(event, *args, namespace=namespace, room=room,
include_self=include_self, callback=callback,
ignore_queue=ignore_queue)
include_self=include_self, skip_sid=skip_sid,
callback=callback, ignore_queue=ignore_queue)


def send(message, **kwargs):
Expand All @@ -797,6 +809,11 @@ def send(message, **kwargs):
:param include_self: ``True`` to include the sender when broadcasting or
addressing a room, or ``False`` to send to everyone
but the sender.
:param skip_sid: The session id of a client to ignore when broadcasting
or addressing a room. This is typically set to the
originator of the message, so that everyone except
that client receive the message. To skip multiple sids
pass a list.
:param ignore_queue: Only used when a message queue is configured. If
set to ``True``, the event is emitted to the
clients directly, without going through the queue.
Expand All @@ -816,12 +833,13 @@ def send(message, **kwargs):
if room is None and not broadcast:
room = flask.request.sid
include_self = kwargs.get('include_self', True)
skip_sid = kwargs.get('skip_sid')
ignore_queue = kwargs.get('ignore_queue', False)

socketio = flask.current_app.extensions['socketio']
return socketio.send(message, json=json, namespace=namespace, room=room,
include_self=include_self, callback=callback,
ignore_queue=ignore_queue)
include_self=include_self, skip_sid=skip_sid,
callback=callback, ignore_queue=ignore_queue)


def join_room(room, sid=None, namespace=None):
Expand Down

0 comments on commit c06e78e

Please sign in to comment.