Exemple #1
0
 function xtestPongMessage()
 {
     $rawPong = "[261, 12345]";
     $pongMsg = Message::createMessageFromRaw($rawPong);
     $this->assertTrue($pongMsg instanceof PongMessage, "Serialized to PongMessage class");
     $this->assertTrue($pongMsg->getRequestId() == 12345, "Request id preserved");
     $this->assertEquals(json_encode(json_decode($rawPong)), $pongMsg->getSerializedMessage(), "Serialized version matches");
     $rawPong = "[261, 12345, {\"test\": \"good\"}, [67890]]";
     $pongMsg = Message::createMessageFromRaw($rawPong);
     $this->assertTrue($pongMsg instanceof PongMessage, "Serialized to PongMessage class");
     /** @var $pongMsg PongMessage */
     $this->assertTrue($pongMsg->getRequestId() == 12345, "Request id preserved");
     $this->assertTrue($pongMsg->getDetails()['test'] == "good", "Details deserialized correctly");
     $this->assertTrue($pongMsg->getEcho()[0] == "67890", "Echo deserialized correctly");
     $this->assertEquals(json_encode(json_decode($rawPong)), $pongMsg->getSerializedMessage(), "Serialized version matches");
 }
Exemple #2
0
 /**
  * This calls an RPC in the InternalClient object that calls ping from the server
  * side and returns the result.
  */
 public function xtestServerPing()
 {
     $this->_conn->on('open', function (\Thruway\ClientSession $session) {
         $session->call('com.example.ping', [])->then(function ($res) {
             $this->_conn->close();
             $this->_testResult = \Thruway\Message\Message::createMessageFromRaw(json_encode($res[0]));
         }, function ($error) {
             $this->_conn->close();
             $this->_error = $error;
         });
     });
     $this->_conn->open();
     $this->assertNull($this->_error, "Got this error when pinging: {$this->_error}");
     $this->assertTrue($this->_testResult instanceof \Thruway\Message\PongMessage);
     $this->assertEquals("echo content", $this->_testResult->getEcho()[0], "Ping echoed correctly");
 }