def open_cont(self, result):
        if self.twsessionstatus != 'auth':
            self.write_tw_error('You are not authenticated.')
            self.close()
            return
        
        self.twconnid = self.application.twconntable.generate_connid()
        uid = self.twsession['uid']
        email = self.twsession['email']
        self.application.twlog.info('Player connected to websocket: %s (session %s, connid %d)', self.twsession['email'], self.twsession['sid'], self.twconnid)

        if not self.application.twservermgr.tworldavailable:
            self.write_tw_error('Tworld service is not available.')
            self.close()
            return

        # Add it to the connection table.
        try:
            self.twconn = self.application.twconntable.add(self, uid, email, self.twsession)
        except Exception as ex:
            self.application.twlog.error('Unable to add connection: %s', ex)
            self.write_tw_error('Unable to add connection: %s' % (ex,))
            self.close()
            return

        # Tell tworld about this new connection. Tworld will send back
        # a reply, at which point we'll mark it available.
        try:
            msg = { 'cmd':'playeropen', 'uid':str(uid), 'email':email }
            self.application.twservermgr.tworld_write(self.twconnid, msg)
        except Exception as ex:
            self.application.twlog.error('Could not write playeropen message to tworld socket: %s', ex)
            # The connection is in the table now, so we'll remove it the
            # fancy way.
            self.twconn.close('Unable to register connection with service: %s' % (ex,))
            return
+
dataset/ETHPy150Open erkyrath/tworld/lib/tweblib/handlers.py/PlayWebSocketHandler.open_cont--crossover with--dataset/ETHPy150Open OpenCobolIDE/OpenCobolIDE/open_cobol_ide/extlibs/future/backports/email/policy.py/EmailPolicy.header_source_parse