Thruway\Procedure::leave PHP Метод

leave() публичный Метод

process session leave
public leave ( Session $session )
$session Session
    public function leave(Session $session)
    {
        // remove all registrations that belong to this session
        /* @var $registration \Thruway\Registration */
        foreach ($this->registrations as $i => $registration) {
            if ($registration->getSession() === $session) {
                // if this session is the callee on pending calls - error them out
                $registration->errorAllPendingCalls();
                array_splice($this->registrations, $i, 1);
            }
        }
    }

Usage Example

Пример #1
0
 public function testLeave()
 {
     $session = $this->getMockBuilder('\\Thruway\\Session')->disableOriginalConstructor()->getMock();
     $session->expects($this->once())->method("sendMessage")->with($this->isInstanceOf('\\Thruway\\Message\\RegisteredMessage'));
     $registerMsg = new \Thruway\Message\RegisterMessage(\Thruway\Common\Utils::getUniqueId(), [], 'test_procedure');
     $this->_proc->processRegister($session, $registerMsg);
     $this->assertEquals(1, count($this->_proc->getRegistrations()));
     $this->_proc->leave($session);
     $this->assertEquals(0, count($this->_proc->getRegistrations()));
 }