

def on_close(self):
    'Callback: web socket has closed. (We also call this manually when\n        manually closing the connection.)\n        '
    if (self.twconnid is None):
        self.application.twlog.warning('PlayWebSocketHandler got on_close while not in table.')
        return
    self.application.twlog.info('Player disconnected from websocket %s', self.twconnid)
    try:
        msg = {
            'cmd': 'playerclose',
        }
        self.application.twservermgr.tworld_write(self.twconnid, msg)
    except Exception as ex:
        self.application.twlog.error('Could not write playerclose message to tworld socket: %s', ex)
    try:
        self.application.twconntable.remove(self)
    except Exception as ex:
        self.application.twlog.error('Error removing connection: %s', ex)
    self.twconnid = None
    self.twconn = None

dataset/ETHPy150Open erkyrath/tworld/lib/tweblib/handlers.py PlayWebSocketHandler.on_close/original