Thruway\Authentication\AbstractAuthProviderClient::onSessionStart PHP Метод

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

Handles session start
public onSessionStart ( ClientSession $session, Thruway\Transport\TransportProviderInterface $transport )
$session Thruway\ClientSession
$transport Thruway\Transport\TransportProviderInterface
    public function onSessionStart($session, $transport)
    {
        $session->register("thruway.auth.{$this->getMethodName()}.onhello", [$this, 'processHello'], ["replace_orphaned_session" => "yes"])->then(function () use($session) {
            $session->register("thruway.auth.{$this->getMethodName()}.onauthenticate", [$this, 'preProcessAuthenticate'], ["replace_orphaned_session" => "yes"])->then(function () use($session) {
                $registrations = new \stdClass();
                $registrations->onhello = "thruway.auth.{$this->getMethodName()}.onhello";
                $registrations->onauthenticate = "thruway.auth.{$this->getMethodName()}.onauthenticate";
                $session->call('thruway.auth.registermethod', [$this->getMethodName(), $registrations, $this->getAuthRealms()])->then(function ($args) {
                    Logger::debug($this, "Authentication Method Registration Successful: {$this->getMethodName()}");
                });
            });
        });
    }

Usage Example

 /**
  * @inheritDoc
  */
 public function onSessionStart($session, $transport)
 {
     parent::onSessionStart($session, $transport);
     $connection = new React\MySQL\Connection($this->getLoop(), array('dbname' => 'thruway_auth_example', 'user' => 'root', 'passwd' => 'root', 'port' => 8889));
     //connecting to mysql server, not required.
     $connection->connect(function () {
     });
     $this->mysqlConnection = $connection;
 }
All Usage Examples Of Thruway\Authentication\AbstractAuthProviderClient::onSessionStart