createProtocol() public method

Put message into newly created protocol and return its wrapper.
public createProtocol ( string | string[] | null $message = null ) : Kraken\Channel\Protocol\ProtocolInterface
$message string | string[] | null
return Kraken\Channel\Protocol\ProtocolInterface
コード例 #1
0
ファイル: Request.php プロジェクト: kraken-php/framework
 /**
  * @param ChannelInterface $channel
  * @param string $name
  * @param string|ProtocolInterface $message
  * @param mixed[] $params
  */
 public function __construct($channel, $name, $message, $params = [])
 {
     $this->channel = $channel;
     $this->name = $name;
     $this->message = $message instanceof ProtocolInterface ? $message : $this->channel->createProtocol($message);
     $this->params = ['timeout' => isset($params['timeout']) ? $params['timeout'] : 2.0, 'retriesLimit' => isset($params['retriesLimit']) ? $params['retriesLimit'] : 10, 'retriesInterval' => isset($params['retriesInterval']) ? $params['retriesInterval'] : 0.25];
     $this->counter = 1;
     $this->message->setTimestamp(TimeSupport::now() + ($this->params['retriesInterval'] + $this->params['timeout']) * 1000.0 * $this->params['retriesLimit'], true);
 }
コード例 #2
0
ファイル: Command.php プロジェクト: kraken-php/framework
 /**
  * @override
  * @inheritDoc
  */
 protected function informServer($commandParent, $commandName, $commandParams = [])
 {
     $protocol = $this->channel->createProtocol(new RuntimeCommand($commandName, $commandParams));
     if ($commandParent !== null) {
         $protocol->setDestination($commandParent);
     }
     $req = new Request($this->channel, $this->receiver, $protocol, ['timeout' => 2, 'retriesLimit' => 10, 'retriesInterval' => 1]);
     return $req->call();
 }