예제 #1
0
 /**
  * @param Character $char
  *
  * @return bool|string
  */
 public function render(Character $char)
 {
     $socket = new CallbackClient($this->socket);
     // outgoing packet
     $msg = new CallbackMessage('RENDER');
     $msg->setPayload($char->getBuffer());
     $socket->sendMessage($msg);
     // incoming packet
     $msg = new CallbackMessage();
     try {
         $socket->waitMessage($msg);
     } catch (\RuntimeException $ex) {
         // received partial message
         // message is not decoded, so getName() will return empty string
     }
     if ($msg->getName() == 'PNG') {
         $result = $msg->getPayload();
         if ($char->isFaceShot()) {
             $result = $this->doFaceShot($char, $result);
         }
     } else {
         $result = false;
     }
     return $result;
 }
예제 #2
0
 public function testSerialIn()
 {
     $buf = "" . "READ" . "payload";
     $in = new MemStream($buf);
     $message = new CallbackMessage();
     $message->serial($in);
     $this->assertEquals('READ', $message->getName());
     $this->assertEquals('payload', $message->getPayload());
 }