Skip to content

Commit

Permalink
Fix handling of argument (Fixes #1441)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Dec 19, 2020
1 parent 2934b46 commit 4ec2748
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions flask_socketio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def ping():
only be used when addressing an individual client.
"""
namespace = kwargs.pop('namespace', '/')
room = kwargs.pop('room', None)
to = kwargs.pop('to', kwargs.pop('room', None))
include_self = kwargs.pop('include_self', True)
skip_sid = kwargs.pop('skip_sid', None)
if not include_self and not skip_sid:
Expand All @@ -458,10 +458,10 @@ def _callback_wrapper(*args):
# we only use it if the emit was issued from a Socket.IO
# populated request context (i.e. request.sid is defined)
callback = _callback_wrapper
self.server.emit(event, *args, namespace=namespace, room=room,
self.server.emit(event, *args, namespace=namespace, to=to,
skip_sid=skip_sid, callback=callback, **kwargs)

def send(self, data, json=False, namespace=None, room=None,
def send(self, data, json=False, namespace=None, to=None,
callback=None, include_self=True, skip_sid=None, **kwargs):
"""Send a server-generated SocketIO message.
Expand Down Expand Up @@ -495,10 +495,10 @@ def send(self, data, json=False, namespace=None, room=None,
"""
skip_sid = flask.request.sid if not include_self else skip_sid
if json:
self.emit('json', data, namespace=namespace, room=room,
self.emit('json', data, namespace=namespace, to=to,
skip_sid=skip_sid, callback=callback, **kwargs)
else:
self.emit('message', data, namespace=namespace, room=room,
self.emit('message', data, namespace=namespace, to=to,
skip_sid=skip_sid, callback=callback, **kwargs)

def close_room(self, room, namespace=None):
Expand Down Expand Up @@ -812,15 +812,15 @@ def handle_my_custom_event(json):
namespace = flask.request.namespace
callback = kwargs.get('callback')
broadcast = kwargs.get('broadcast')
room = kwargs.get('room')
if room is None and not broadcast:
room = flask.request.sid
to = kwargs.pop('to', kwargs.pop('room', None))
if to is None and not broadcast:
to = 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,
return socketio.emit(event, *args, namespace=namespace, to=to,
include_self=include_self, skip_sid=skip_sid,
callback=callback, ignore_queue=ignore_queue)

Expand Down Expand Up @@ -870,15 +870,15 @@ def send(message, **kwargs):
namespace = flask.request.namespace
callback = kwargs.get('callback')
broadcast = kwargs.get('broadcast')
room = kwargs.get('room')
if room is None and not broadcast:
room = flask.request.sid
to = kwargs.pop('to', kwargs.pop('room', None))
if to is None and not broadcast:
to = 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,
return socketio.send(message, json=json, namespace=namespace, to=to,
include_self=include_self, skip_sid=skip_sid,
callback=callback, ignore_queue=ignore_queue)

Expand Down

0 comments on commit 4ec2748

Please sign in to comment.