javascript - Restarting Supervisor and effect on FlaskSocketIO -
in index.html (html/javascript)
have:
$(document).ready(function(){ namespace = '/test'; var socket = io.connect('http://' + document.domain + ':' + location.port + namespace); socket.on('connect', function() { socket.emit('join', {room: 'venue_1'}); }); socket.on('my response', function(msg) { $('#log').append('<br>received #' + ': ' + msg.data); }); });
on server
have:
@socketio.on('connect', namespace='/test') def test_connect(): if session.get('venue_id'): emit('my response', {'data': 'connected'}) session.pop('venue_id', none) else: request.namespace.disconnect() @socketio.on('join', namespace='/test') def join(message): join_room(message['room']) room = message['room'] emit('my response', {'data': 'entered room ' + message['room']})
after logging in, set session['venue_id'] = true
, move index.html
. output is:
received #: connected received #: entered room venue_1
my question: after initial run, keep index.html
page open , stop
, start
project through supervisor
. @ point why same output above? have thought after initial connect
, venue_id
have been removed session
, hence request.namespace.disconnect()
called?
could please explain me sequence of events here?
thanks
the socket.io client has reconnect logic built in. if server goes away there expected disconnect, right away client starts connect again, , succeeds since restart has short down time.
Comments
Post a Comment