/** * creting new user, and adding this user to user manager * return session user public session * public session are session visible to other users * @param UserItems_I_UserItems $userItem * @param Socket_Client $socketClient * @return string Session_Session::generate(); */ public function add(UserItems_A_UserItems $userItem, Socket_Client $socketClient) { $session = Session_Session::generate(); while (array_key_exists($session, $this->users)) { $session = Session_Session::generate(); } $this->users[$session] = new User_User($session, $userItem, $socketClient); return $session; }
/** * adding new socket client * @param $socketClient Socket_Client */ public function add(Socket_Client $socketClient) { $unique = false; while ($unique == false) { $session = Session_Session::generate(); foreach ($this->items as $items) { if ($items->getSession() == $session) { continue; } } $unique = true; } $socketClient->setSession($session); $this->items[$socketClient->getSocketInstance()] = $socketClient; }