Exemplo n.º 1
0
 def on_close(self):
     if self in WebSocketHandler.users:
         if self.current_user:
             WebSocketHandler.online.remove(self.user_id)
             rd.srem("online", self.user_id)
         WebSocketHandler.users.remove(self)
         self.on_message("offline")
Exemplo n.º 2
0
 def on_close(self):
     if self in WebSocketHandler.users:
         if self.current_user:
             try:
                 WebSocketHandler.online.remove(self.user_id)
             except:
                 pass
             rd.srem("online", self.user_id)
         WebSocketHandler.users.remove(self)
         logging.info("%s offline" % self.user_id)
         WebSocketHandler.send_online()
Exemplo n.º 3
0
 def on_close(self):
     if self in WebSocketHandler.users:
         if self.current_user:
             try:
                 WebSocketHandler.online.remove(self.user_id)
             except:
                 pass
             rd.srem("online", self.user_id)
         WebSocketHandler.users.remove(self)
         logging.info("%s offline" % self.user_id)
         WebSocketHandler.send_online()
Exemplo n.º 4
0
 def send_online(cls):
     online = rd.smembers("online")
     logging.info("Online user count is " + unicode(len(online)))
     for user in cls.users:
         try:
             user.write_message({"type": "online", "count": unicode(len(online))})
         except Exception as e:
             logging.error("Error sending online user count", exc_info=True)
             if type(e).__name__ == "AttributeError":
                 try:
                     WebSocketHandler.users.remove(user)
                     rd.srem("online", user.user_id)
                     WebSocketHandler.online.remove(user.user_id)
                 except:
                     pass
Exemplo n.º 5
0
 def send_online(cls):
     online = rd.smembers("online")
     logging.info("Online user count is " + unicode(len(online)))
     for user in cls.users:
         try:
             user.write_message({
                 "type": "online",
                 "count": unicode(len(online))
             })
         except Exception as e:
             logging.error("Error sending online user count", exc_info=True)
             if type(e).__name__ == "AttributeError":
                 try:
                     WebSocketHandler.users.remove(user)
                     rd.srem("online", user.user_id)
                     WebSocketHandler.online.remove(user.user_id)
                 except:
                     pass