Example #1
0
 /**
  * @depends testJoin
  *
  * @param \Thruway\Session $session
  */
 public function testGoodbyeMessage(\Thruway\Session $session)
 {
     $realm = $session->getRealm();
     $sessions = $realm->managerGetSessions();
     $this->assertEquals(1, count($sessions));
     $goodbyeMessage = new \Thruway\Message\GoodbyeMessage([], 'some_test_reason');
     $realm->handleGoodbyeMessage(new \Thruway\Event\MessageEvent($session, $goodbyeMessage));
     $sessions = $realm->managerGetSessions();
     $this->assertEquals(0, count($sessions));
 }
Example #2
0
 /**
  * @depends testJoin
  *
  * @param \Thruway\Session $session
  */
 public function testGoodbyeMessage(\Thruway\Session $session)
 {
     $realm = $session->getRealm();
     $sessions = $realm->managerGetSessions();
     $this->assertEquals(1, count($sessions));
     $realm->onMessage($session, new \Thruway\Message\GoodbyeMessage([], 'some_test_reason'));
     $this->assertInstanceOf('\\Thruway\\Message\\GoodbyeMessage', $session->getTransport()->getLastMessageSent());
     $sessions = $realm->managerGetSessions();
     $this->assertEquals(0, count($sessions));
 }
Example #3
0
 /**
  * Process on session leave
  *
  * @param \Thruway\Session $session
  */
 public function leave(Session $session)
 {
     Logger::debug($this, "Leaving realm {$session->getRealm()->getRealmName()}");
     $this->sessions->detach($session);
 }
Example #4
0
 /**
  * Process on session leave
  *
  * @param \Thruway\Session $session
  */
 public function leave(Session $session)
 {
     Logger::debug($this, "Leaving realm {$session->getRealm()->getRealmName()}");
     if ($this->getAuthenticationManager() !== null) {
         $this->getAuthenticationManager()->onSessionClose($session);
     }
     foreach ($this->roles as $role) {
         $role->leave($session);
     }
     $this->sessions->detach($session);
 }
 /**
  * This allows the AuthenticationManager to clean out auth methods that were registered by
  * sessions that are dieing. Otherwise the method could be hijacked by another client in the
  * thruway.auth realm.
  *
  * @param \Thruway\Session $session
  */
 public function onSessionClose(Session $session)
 {
     if ($session->getRealm() && $session->getRealm()->getRealmName() == "thruway.auth") {
         // session is closing in the auth domain
         // check and see if there are any registrations that came from this session
         $sessionId = $session->getSessionId();
         foreach ($this->authMethods as $methodName => $method) {
             if (isset($method['session_id']) && $method['session_id'] == $sessionId) {
                 unset($this->authMethods[$methodName]);
             }
         }
     }
 }