Example #1
0
 /**
  * @param AbstractMessage $message
  *
  * @return \Generator
  */
 public function handle(AbstractMessage $message, AbstractProtocol $protocol) : \Generator
 {
     $client = $message->getFrom();
     $clientId = $client->getId();
     $this->logger->debug("New payload", ['clientId' => $clientId]);
     $context = $this->clientContexts[$clientId] ?? $this->buildContext($message, $protocol);
     if (is_callable($context)) {
         (yield $context($message, $client));
         $isResolved = true;
     } elseif ($context instanceof ContextInterface) {
         (yield $context->handle($message));
         $isResolved = $context->isResolved();
     }
     if ($isResolved) {
         $this->terminateContext($clientId);
     }
     return true;
 }
Example #2
0
 /**
  * @param float           $longitude
  * @param float           $latitude
  * @param ClientInterface $from
  * @param ClientInterface $user
  */
 public function __construct(float $longitude, float $latitude, ClientInterface $from, ClientInterface $user)
 {
     parent::__construct($from, $user);
     $this->longitude = $longitude;
     $this->latitude = $latitude;
 }
Example #3
0
 /**
  * @param string|string   $text
  * @param ClientInterface $from
  * @param ClientInterface $user
  */
 public function __construct(string $text, ClientInterface $from, ClientInterface $user)
 {
     parent::__construct($from, $user);
     $this->text = $text;
 }