Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Update #1130

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion flask_socketio/__init__.py
Expand Up @@ -33,6 +33,7 @@ class _SocketIOMiddleware(socketio.WSGIApp):
"""This WSGI middleware simply exposes the Flask application in the WSGI
environment before executing the request.
"""

def __init__(self, socketio_app, flask_app, socketio_path='socket.io'):
self.flask_app = flask_app
super(_SocketIOMiddleware, self).__init__(socketio_app,
Expand Down Expand Up @@ -211,6 +212,10 @@ def init_app(self, app, **kwargs):
queue = queue_class(url, channel=channel,
write_only=write_only)
self.server_options['client_manager'] = queue
elif app is not None and self.server_options['client_manager'].write_only:
# If using the .init_app() method with message_queue specified ONLY in the SocketIO constructor,
# this will switch the client back into read/write mode.
self.server_options['client_manager'].write_only = False

if 'json' in self.server_options and \
self.server_options['json'] == flask_json:
Expand All @@ -232,7 +237,7 @@ def loads(*args, **kwargs):
self.server_options['json'] = FlaskSafeJSON

resource = self.server_options.pop('path', None) or \
self.server_options.pop('resource', None) or 'socket.io'
self.server_options.pop('resource', None) or 'socket.io'
if resource.startswith('/'):
resource = resource[1:]
if os.environ.get('FLASK_RUN_FROM_CLI'):
Expand Down Expand Up @@ -288,6 +293,7 @@ def _handler(sid, *args):
else:
self.handlers.append((message, _handler, namespace))
return handler

return decorator

def on_error(self, namespace=None):
Expand All @@ -312,6 +318,7 @@ def decorator(exception_handler):
raise ValueError('exception_handler must be callable')
self.exception_handlers[namespace] = exception_handler
return exception_handler

return decorator

def on_error_default(self, exception_handler):
Expand Down