Kraken\Channel\Protocol\ProtocolInterface::setTimestamp PHP Method

setTimestamp() public method

This method sets timestamp only if it was not set already. To force replacement $reassing flag needs to be set to true.
public setTimestamp ( integer $timestamp, boolean $reassign = false ) : Kraken\Channel\Protocol\ProtocolInterface
$timestamp integer
$reassign boolean
return Kraken\Channel\Protocol\ProtocolInterface
    public function setTimestamp($timestamp, $reassign = false);

Usage Example

Example #1
0
 /**
  * @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);
 }