Ejemplo n.º 1
0
    def userOnline(self):
        self.user = unicode(self.get_argument("u", None))
        self.passwd = self.get_argument("p", None)

        res = yield self.auth()
        if res['err']:
            print "auth failed"
            self.close()
            raise gen.Return(res)

        old_session = UserSession.getSession(self.user)
        if old_session:
            msg = json.dumps({
                'c': 'CHANGE_DEVICE',
                'time': time.time(),
                'msg': '',
            })
            try:
                old_session.write_message(msg)
            except:
                pass

        UserSession.addSession(self.user, self)
        processor = ChatProcessor(self.user)
        processor.userOnline()

        print "user online:", self.user, type(self.user)
Ejemplo n.º 2
0
 def client(self):
     return UserSession.getSession(self.user)