In my index.html (HTML/Javascript)
I 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 my Server
I 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 the room ' + message['room']})
After logging in, I set session['venue_id'] = True
and move to index.html
. The output I get is:
Received #: Connected
Received #: Entered the room venue_1
My question: After the initial run, I keep the index.html
page open and then stop
and start
my project through supervisor
. At this point why do I get the same output as above? I would have thought that after the initial connect
, venue_id
would have been removed from the session
and hence request.namespace.disconnect()
would be called?
Could someone please explain to me the sequence of events here?
Thanks