/** * @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; }
/** * @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; }
/** * @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; }