fix empty name for lobby
This commit is contained in:
parent
76e74fbd43
commit
3ba7f60fdb
@ -26,15 +26,15 @@ def advertise_lobbies():
|
|||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
def connect(sid, environ):
|
def connect(sid, environ):
|
||||||
|
global online_players
|
||||||
|
online_players += 1
|
||||||
print('connect ', sid)
|
print('connect ', sid)
|
||||||
sio.enter_room(sid, 'lobby')
|
sio.enter_room(sid, 'lobby')
|
||||||
sio.emit('players', room='lobby', data=online_players)
|
sio.emit('players', room='lobby', data=online_players)
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
def set_username(sid, username):
|
def set_username(sid, username):
|
||||||
global online_players
|
|
||||||
if not isinstance(sio.get_session(sid), Player):
|
if not isinstance(sio.get_session(sid), Player):
|
||||||
online_players += 1
|
|
||||||
sio.save_session(sid, Player(username, sid, sio))
|
sio.save_session(sid, Player(username, sid, sio))
|
||||||
print(f'{sid} is now {username}')
|
print(f'{sid} is now {username}')
|
||||||
advertise_lobbies()
|
advertise_lobbies()
|
||||||
@ -69,8 +69,8 @@ def get_me(sid, room):
|
|||||||
@sio.event
|
@sio.event
|
||||||
def disconnect(sid):
|
def disconnect(sid):
|
||||||
global online_players
|
global online_players
|
||||||
|
online_players -= 1
|
||||||
if sio.get_session(sid):
|
if sio.get_session(sid):
|
||||||
online_players -= 1
|
|
||||||
sio.emit('players', room='lobby', data=online_players)
|
sio.emit('players', room='lobby', data=online_players)
|
||||||
if sio.get_session(sid).game and sio.get_session(sid).disconnect():
|
if sio.get_session(sid).game and sio.get_session(sid).disconnect():
|
||||||
sio.close_room(sio.get_session(sid).game.name)
|
sio.close_room(sio.get_session(sid).game.name)
|
||||||
|
@ -223,6 +223,8 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
console.log('mounted lobby')
|
console.log('mounted lobby')
|
||||||
|
if (!this.$route.query.code)
|
||||||
|
return this.$router.push('/')
|
||||||
this.$socket.emit('get_me', {name:this.$route.query.code, password:this.$route.query.pwd})
|
this.$socket.emit('get_me', {name:this.$route.query.code, password:this.$route.query.pwd})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user