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")
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()
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
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