javascript - Socket.io emits to non-existing room -


i'm writing game , using socket.io. every map in game represented room in socket.io.

it works this. user runs client , joins main room (lobby) empty room "" in socket.io, there, user can create room, roomid number, starting 0 (0,1,2,3, etc). when user joins room, starts timer - countdown till end of current map.

 __starttimer:function() {     this.__timerid=setinterval(this.__ontimertick.bind(this), 1000); },  __ontimertick:function() {     var string="timer event in room "+this.__roomid+", list of socket.io rooms:";     console.log(string);     console.log(g.socketio.sockets.manager.rooms);      this.__duration--;     g.socketio.sockets.in(this.__roomid).emit(g.messages.fight_timer_tick_event, {time: this.__duration});     if(this.__duration==0)     {         clearinterval(this.__timerid);         this.__fightend();     } }, 

the problem that, when users close client, leaves room, , if there no more users in room, destroyed. when user runs client again, joins lobby, socket.io starts emitting timer event lobby room. emiting wrong room.

log:

info: socket.io started debug: client authorized info: handshake authorized ife6tqsa_lthtxv8wsoi debug: setting request /socket.io/1/flashsocket/ife6tqsa_lthtxv8wsoi debug: set heartbeat interval client ife6tqsa_lthtxv8wsoi debug: client authorized   timer event in room 0, list of socket.io rooms: { '': [ 'ife6tqsa_lthtxv8wsoi' ],   '/0': [ 'ife6tqsa_lthtxv8wsoi' ] } debug: flashsocket writing 5:::{"name":"104","args":[{"time":179}]} timer event in room 0, list of socket.io rooms: { '': [ 'ife6tqsa_lthtxv8wsoi' ],   '/0': [ 'ife6tqsa_lthtxv8wsoi' ] } debug: flashsocket writing 5:::{"name":"104","args":[{"time":178}]} timer event in room 0, list of socket.io rooms: { '': [ 'ife6tqsa_lthtxv8wsoi' ],   '/0': [ 'ife6tqsa_lthtxv8wsoi' ] } debug: flashsocket writing 5:::{"name":"104","args":[{"time":177}]}  info: transport end (socket end) debug: set close timeout client ife6tqsa_lthtxv8wsoi debug: cleared close timeout client ife6tqsa_lthtxv8wsoi debug: cleared heartbeat interval client ife6tqsa_lthtxv8wsoi debug: discarding transport  timer event in room 0, list of socket.io rooms: {} timer event in room 0, list of socket.io rooms: {} timer event in room 0, list of socket.io rooms: {} timer event in room 0, list of socket.io rooms: {}  debug: client authorized info: handshake authorized z540akrvwab5x4lzwsoj debug: setting request /socket.io/1/flashsocket/z540akrvwab5x4lzwsoj debug: set heartbeat interval client z540akrvwab5x4lzwsoj debug: client authorized   timer event in room 0, list of socket.io rooms: { '': [ 'z540akrvwab5x4lzwsoj' ] } debug: flashsocket writing 5:::{"name":"104","args":[{"time":158}]} timer event in room 0, list of socket.io rooms: { '': [ 'z540akrvwab5x4lzwsoj' ] } 

i think problem in this: "starting 0". dont use 0 room name.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -