mirror of
https://github.com/solero/houdini.git
synced 2024-11-10 05:08:19 +00:00
Move client disconnect functionality into dummy event listener
This commit is contained in:
parent
c9996c57e7
commit
78d042b1a3
@ -59,3 +59,16 @@ async def handle_join_room(p, room: Room, x: int, y: int):
|
||||
@handlers.handler(XTPacket('j', 'grs'))
|
||||
async def handle_refresh_room(p):
|
||||
await p.room.refresh(p)
|
||||
|
||||
|
||||
@handlers.disconnected
|
||||
@handlers.player_attribute(joined_world=True)
|
||||
async def handle_disconnect_room(p):
|
||||
await p.room.remove_penguin(p)
|
||||
|
||||
del p.server.penguins_by_id[p.data.id]
|
||||
del p.server.penguins_by_username[p.data.username]
|
||||
|
||||
server_key = '{}.players'.format(p.server.server_config['Id'])
|
||||
await p.server.redis.srem(server_key, p.data.id)
|
||||
await p.server.redis.hincrby('population', p.server.server_config['Id'], -1)
|
||||
|
@ -311,18 +311,6 @@ class Penguin(Spheniscidae):
|
||||
'{} removed their background item'.format(
|
||||
self.data.username))
|
||||
|
||||
async def _client_disconnected(self):
|
||||
if self.joined_world:
|
||||
if self.room is not None:
|
||||
await self.room.remove_penguin(self)
|
||||
|
||||
del self.server.penguins_by_id[self.data.id]
|
||||
del self.server.penguins_by_username[self.data.username]
|
||||
|
||||
await self.server.redis.hincrby('population', self.server.server_config['Id'], -1)
|
||||
|
||||
await super()._client_disconnected()
|
||||
|
||||
def __repr__(self):
|
||||
if self.data is not None:
|
||||
return '<Penguin ID=\'{}\' Username=\'{}\'>'.format(self.data.id, self.data.username)
|
||||
|
Loading…
Reference in New Issue
Block a user