Skip to content

Commit

Permalink
More robust handling of to and room arguments (Fixes #1771)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Apr 29, 2022
1 parent bafdfc2 commit f7ca69a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/flask_socketio/__init__.py
Expand Up @@ -434,7 +434,7 @@ def ping():
only be used when addressing an individual client.
"""
namespace = kwargs.pop('namespace', '/')
to = kwargs.pop('to', kwargs.pop('room', None))
to = kwargs.pop('to', None) or 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 Down Expand Up @@ -827,7 +827,7 @@ def handle_my_custom_event(json):
namespace = flask.request.namespace
callback = kwargs.get('callback')
broadcast = kwargs.get('broadcast')
to = kwargs.pop('to', kwargs.pop('room', None))
to = kwargs.pop('to', None) or kwargs.pop('room', None)
if to is None and not broadcast:
to = flask.request.sid
include_self = kwargs.get('include_self', True)
Expand Down Expand Up @@ -885,7 +885,7 @@ def send(message, **kwargs):
namespace = flask.request.namespace
callback = kwargs.get('callback')
broadcast = kwargs.get('broadcast')
to = kwargs.pop('to', kwargs.pop('room', None))
to = kwargs.pop('to', None) or kwargs.pop('room', None)
if to is None and not broadcast:
to = flask.request.sid
include_self = kwargs.get('include_self', True)
Expand Down

0 comments on commit f7ca69a

Please sign in to comment.