/** {@inheritdoc} */
 public function invokeEvent(Event $event)
 {
     switch ($event->getType()) {
         case EventType::INITIALIZE:
             $this->onSocketRequestInitialize();
             break;
         case EventType::FINALIZE:
             $this->onSocketRequestFinalize();
             break;
     }
 }
 /** {@inheritdoc} */
 public function invokeEvent(Event $event)
 {
     switch ($event->getType()) {
         case EventType::DATA_ALERT:
             /** @var DataAlertEvent $event */
             $this->onDataAlert($event);
             break;
         case EventType::READ:
             /** @var ReadEvent $event */
             $this->onRead($event);
             break;
         default:
             $this->callNextHandler($event);
     }
 }
예제 #3
0
 /**
  * TimeoutEvent constructor.
  *
  * @param RequestExecutorInterface $executor Request executor object
  * @param SocketInterface          $socket   Socket for this request
  * @param mixed                    $context  Any optional user data for event
  * @param string                   $when One of DURING_* constants
  */
 public function __construct(RequestExecutorInterface $executor, SocketInterface $socket, $context, $when)
 {
     parent::__construct($executor, $socket, $context, EventType::TIMEOUT);
     $this->when = $when;
 }
예제 #4
0
 /**
  * Constructor
  *
  * @param RequestExecutorInterface $executor Request executor object
  * @param SocketInterface          $serverSocket Server socket for this request
  * @param mixed                    $context  Any optional user data for event
  * @param SocketInterface          $clientSocket Accepted client socket
  * @param string                   $remoteAddress Remote address
  */
 public function __construct(RequestExecutorInterface $executor, SocketInterface $serverSocket, $context, SocketInterface $clientSocket, $remoteAddress)
 {
     parent::__construct($executor, $serverSocket, $context, EventType::ACCEPT);
     $this->clientSocket = $clientSocket;
     $this->remoteAddress = $remoteAddress;
 }
 /** {@inheritdoc} */
 public function invokeEvent(Event $event)
 {
     $eventName = $event->getType();
     $subscribers = isset($this->handlers[$eventName]) ? $this->handlers[$eventName] : [];
     foreach ($subscribers as $subscriber) {
         call_user_func($subscriber, $event);
     }
 }
 /**
  * Constructor
  *
  * @param SocketException          $exception Exception occurred during request
  * @param RequestExecutorInterface $executor Request executor object
  * @param SocketInterface          $socket   Socket for this request
  * @param mixed                    $context  Any optional user data for event
  */
 public function __construct(SocketException $exception, RequestExecutorInterface $executor, SocketInterface $socket, $context)
 {
     parent::__construct($executor, $socket, $context, EventType::EXCEPTION);
     $this->exception = $exception;
 }