diff --git a/example/app.py b/example/app.py index 53983151..2e362ab5 100755 --- a/example/app.py +++ b/example/app.py @@ -65,12 +65,12 @@ def leave(message): 'count': session['receive_count']}) -@socketio.event -def close_room(message): +@socketio.on('close_room') +def on_close_room(message): session['receive_count'] = session.get('receive_count', 0) + 1 emit('my_response', {'data': 'Room ' + message['room'] + ' is closing.', 'count': session['receive_count']}, - room=message['room']) + to=message['room']) close_room(message['room']) @@ -79,7 +79,7 @@ def my_room_event(message): session['receive_count'] = session.get('receive_count', 0) + 1 emit('my_response', {'data': message['data'], 'count': session['receive_count']}, - room=message['room']) + to=message['room']) @socketio.event diff --git a/flask_socketio/__init__.py b/flask_socketio/__init__.py index 9d9de700..045af753 100644 --- a/flask_socketio/__init__.py +++ b/flask_socketio/__init__.py @@ -417,9 +417,9 @@ def ping(): :param args: A dictionary with the JSON data to send as payload. :param namespace: The namespace under which the message is to be sent. Defaults to the global namespace. - :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 to: 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. @@ -476,9 +476,9 @@ def send(self, data, json=False, namespace=None, room=None, otherwise. :param namespace: The namespace under which the message is to be sent. Defaults to the global namespace. - :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 to: 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. @@ -721,7 +721,6 @@ def test_client(self, app, namespace=None, query_string=None, flask_test_client=flask_test_client) def _handle_event(self, handler, message, namespace, sid, *args): - eio_sid = self.server.manager.eio_sid_from_sid(sid, namespace) environ = self.server.get_environ(sid, namespace=namespace) if not environ: # we don't have record of this client, ignore this event @@ -788,8 +787,9 @@ def handle_my_custom_event(json): acknowledgement. :param broadcast: ``True`` to send the message to all clients, or ``False`` to only reply to the sender of the originating event. - :param room: Send the message to all the users in the given room. If this - argument is set, then broadcast is implied to be ``True``. + :param to: Send the message to all the users in the given room. If this + argument is not set and ``broadcast`` is ``False``, then the + message is sent only to the originating user. :param include_self: ``True`` to include the sender when broadcasting or addressing a room, or ``False`` to send to everyone but the sender. @@ -844,7 +844,9 @@ def send(message, **kwargs): :param broadcast: ``True`` to send the message to all connected clients, or ``False`` to only reply to the sender of the originating event. - :param room: Send the message to all the users in the given room. + :param to: Send the message to all the users in the given room. If this + argument is not set and ``broadcast`` is ``False``, then the + message is sent only to the originating user. :param include_self: ``True`` to include the sender when broadcasting or addressing a room, or ``False`` to send to everyone but the sender.