def user_exit(sid): if Relay.is_admin(sid) == True: Relay.kill_admin(sid) print('这个http服务器的管理员退出了', sid) return user = Relay.get_user_by_sid(sid) if user is not None: user_id = user.get_id() Relay.user_exit(user_id) print('这个普通用户退出了', sid) print(sid, '退出了推送系统') return
def update(self): del_list = list() for user_id, user in self._user_dict.items(): if user.has_heartbeat() is True: continue del_list.append(user_id) for user_id in del_list: Relay.user_exit(user_id) # 更新用户管理器 exit_admin = [] for admin_sid, last_connect_time in self._admin_dict.items(): if int(time.time()) - last_connect_time > 10: exit_admin.append(admin_sid) for i in exit_admin: self._admin_dict.pop(i) print('管理员', i, '长时间无心跳,已被杀死') return