/** * Creates an instance from the Message. * * @param Message $msg * * @return QueueStatusResponse */ public static function fromMessage(Message $msg) { $queueStatus = array(); while ($msg->peek() !== null) { $action = $msg->shift(); $queueStatus[$action] = array('action' => $action, 'queue' => $msg->shift(), 'busy' => $msg->shift(), 'available' => $msg->shift()); } return new self($queueStatus); }
/** * Creates an instance based on the Message. * * @param Message $msg * * @return WorkerHandlerStatus */ public static function fromMessage(Message $msg) { $workerHandlerId = $msg->shift(); $requestId = $msg->shift(); if (!$requestId) { $requestId = null; } return new self($workerHandlerId, $requestId); }
/** * Create a Message with the given Type. * * @param Message $msg * * @return MessageInterface * @throws UnknownProtocolVersionException */ public static function createProtocolMessage(Message $msg) { $version = $msg->shift(); if (!self::hasProtocolVersion($version)) { throw new UnknownProtocolVersionException(); } $type = $msg->shift(); $class = self::getClassByType($type); return $class::fromMessage($msg); }
public function testShiftReturnsTheFirstPartAndRemovesIt() { $msg = new Message(array('hello', 'world')); $this->assertEquals('hello', $msg->shift()); $this->assertSame(1, $msg->count()); $this->assertEquals('world', $msg->peek()); }
/** * Creates a FetchAction message from the Message. * * @param \AlphaRPC\Common\Socket\Message $msg * * @throws InvalidArgumentException * * @return self */ public static function fromMessage(Message $msg) { $count = $msg->shift(); if ($count != $msg->count()) { throw new InvalidArgumentException('The action count is not the same as the actual number of actions.'); } return new self($msg->toArray()); }
/** * Creates an instance from the Message. * * @param Message $msg * * @return WorkerStatusResponse */ public static function fromMessage(Message $msg) { $workerStatus = array(); while ($msg->peek() !== null) { $id = $msg->shift(); $actionCount = (int) $msg->shift(); $actionList = array(); for ($i = 0; $i < $actionCount; $i++) { $actionList[] = $msg->shift(); } $workerStatus[$id] = array('id' => $id, 'actionList' => $actionList, 'current' => $msg->shift(), 'ready' => (bool) $msg->shift(), 'valid' => (bool) $msg->shift()); } return new self($workerStatus); }
/** * Creates a FetchAction message from the Message. * * @param \AlphaRPC\Common\Socket\Message $msg * * @return StorageStatus */ public static function fromMessage(Message $msg) { return new static($msg->shift(), $msg->shift()); }
/** * Creates an instance from the Message. * * @param Message $msg * * @return ClientHandlerJobRequest */ public static function fromMessage(Message $msg) { $requestId = $msg->shift(); $actionName = $msg->shift(); $parameters = $msg->toArray(); return new self($requestId, $actionName, $parameters); }
/** * Creates an instance of this class based on the Message. * * @param Message $msg * * @return ExecuteRequest */ public static function fromMessage(Message $msg) { return new self($msg->shift(), $msg->shift(), $msg->toArray()); }
/** * Creates an instance of this class based on the Message. * * @param Message $msg * * @return ExecuteResponse */ public static function fromMessage(Message $msg) { $request_id = $msg->shift(); $result = $msg->shift() ?: ''; return new self($request_id, $result); }