/** * 向群中添加用户、删除用户 */ public static function setGroupMembers($paramArr) { $options = array('master' => '', 'uuid' => '', 'type' => 'add', 'userList' => array(), 'joinTime' => time()); if (is_array($paramArr)) { $options = array_merge($options, $paramArr); } extract($options); if (!is_array($userList)) { return false; } $key = self::groupMembersKey($master, $uuid); if (!$key) { return false; } foreach ($userList as $user) { if ($type === 'add') { RedisModel::hashSet(self::$redisServer, $key, $user, $joinTime, 0); } elseif ($type === 'del') { RedisModel::hashDel(self::$redisServer, $key, $user); } } return RedisModel::exists(self::$redisServer, $key); }
/** * 存储用户到在线列表 * @param int $client_id * @param string $clientName */ public static function addUserToOnlineList($clientId, $clientName) { $key = Storekey::USER_ONLINE_LIST; // 获取所有所有在线用户clientid-------------- $allOnlineClientId = Gateway::getOnlineStatus(); //获取存储中在线用户列表 $clientList = Muser::getOnlineUsers(); if (isset($clientList[$clientId])) { return true; } //是否允许多用户登录,剔除用户的clientid if (\Config\St\Status::NOT_ALLOW_CLIENTS) { self::notAllowMoreClient($clientList, $clientName); } // 将存储中不在线用户删除 self::deleteOfflineUser($clientList, $allOnlineClientId); // 添加 时间默认是一天 if (RedisModel::hashSet('webChat', $key, $clientId, $clientName)) { return true; } return false; }