public function createMessagePong(Message $ping) { if ($ping->getType() !== Message::TYPE_ECHO_REQUEST) { throw new InvalidArgumentException(); } return new Message(Message::TYPE_ECHO_REPLY, 0, null, $ping->getHeader(), $ping->getPayload()); }
public function sendMessage(Message $message, $remoteAddress) { // echo 'send to ' . $remoteAddress . PHP_EOL; // $hex = new Hexdump(); // $hex->dump($message); $this->socket->send($message->getMessagePacket(), $remoteAddress); }
/** * passing NULL as the checksum should automatically update the checksum to the valid, calculated value */ public function testAutomaticMessageChecksum() { $message = new Message(1, 2, null, 3); $this->assertNotNull($message->getChecksum()); $this->assertTrue($message->isChecksumValid()); }