diff --git a/flask_socketio/__init__.py b/flask_socketio/__init__.py index edc1752b..d5c8fdd0 100644 --- a/flask_socketio/__init__.py +++ b/flask_socketio/__init__.py @@ -314,9 +314,10 @@ 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 + that client receive the message. :param callback: If given, this function will be called to acknowledge that the client has received the message. The arguments that will be passed to the function are @@ -324,13 +325,13 @@ def ping(): only be used when addressing an individual client. """ skip_sid = flask.request.sid \ - if not kwargs.get('include_self', True) else None + if not kwargs.get('include_self', True) else kwargs.get('skip_sid') self.server.emit(event, *args, namespace=kwargs.get('namespace', '/'), room=kwargs.get('room'), skip_sid=skip_sid, callback=kwargs.get('callback')) def send(self, data, json=False, namespace=None, room=None, - callback=None, include_self=True): + callback=None, include_self=True, skip_sid=None): """Send a server-generated SocketIO message. This function sends a simple SocketIO message to one or more connected @@ -347,16 +348,17 @@ 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 + that client receive the message. :param callback: If given, this function will be called to acknowledge that the client 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. """ - skip_sid = flask.request.sid if not include_self else None + skip_sid = flask.request.sid if not include_self else skip_sid if json: self.emit('json', data, namespace=namespace, room=room, skip_sid=skip_sid, callback=callback)