def on_close(self):
        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)
        # Tell tworld that the connection is closed. (Maybe it never
        # became available, but we'll send the message anyway.)
        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)
        # Remove the connection from our table.
        try:
            self.application.twconntable.remove(self)
        except Exception as ex:
            self.application.twlog.error('Error removing connection: %s', ex)
        # Clean up dangling fields, and drop self forever.
        self.twconnid = None
        self.twconn = None
Callback: web socket has closed. (We also call this manually when
dataset/ETHPy150Open erkyrath/tworld/lib/tweblib/handlers.py/PlayWebSocketHandler.on_close