コード例 #1
0
ファイル: run_server.py プロジェクト: eeue56/PyChat.js
    def open(self):
        print 'new connection'

        self.write_message('Connected successfully\n')

        # set a temp name
        id_ = User(user_server)

        self.connection = ChatConnection(id_, self, rooms)
        self.parser = Parser(self.connection)

        logging.info('User with name {name} joined!'.format(name=id_))
コード例 #2
0
ファイル: run_server.py プロジェクト: eeue56/PyChat.js
class WSHandler(tornado.websocket.WebSocketHandler):
    def open(self):
        print 'new connection'

        self.write_message('Connected successfully\n')

        # set a temp name
        id_ = User(user_server)

        self.connection = ChatConnection(id_, self, rooms)
        self.parser = Parser(self.connection)

        logging.info('User with name {name} joined!'.format(name=id_))

    def on_message(self, message):
        logging.info('Message {mes} recieved from user {id}'.format(mes=message, 
            id=self.parser.connection.id))

        self.parser.parse_message(message)
    
    def on_close(self):
        logging.info('User {id} disconnected!'.format(id=self.parser.connection.id))
        self.connection.close()