getPayload() public method

public getPayload ( ) : string
return string
コード例 #1
0
ファイル: Connection.php プロジェクト: luoshulin/falcon
 /**
  * Handle a complete payload received from the client
  *
  * Public because called from our PayloadHandler
  *
  * @param string $payload
  */
 public function handlePayload(Payload $payload)
 {
     $app = $this->getClientApplication();
     $this->log('Handling payload: ' . $payload->getPayload(), 'debug');
     switch ($type = $payload->getType()) {
         case Protocol::TYPE_TEXT:
             if (method_exists($app, 'onData')) {
                 $app->onData($payload, $this);
             }
             return;
         case Protocol::TYPE_BINARY:
             if (method_exists($app, 'onBinaryData')) {
                 $app->onBinaryData($payload, $this);
             } else {
                 $this->close(1003);
             }
             break;
         case Protocol::TYPE_PING:
             $this->log('Ping received', 'notice');
             $this->send($payload->getPayload(), Protocol::TYPE_PONG);
             $this->log('Pong!', 'debug');
             break;
             /**
              * A Pong frame MAY be sent unsolicited.  This serves as a
              * unidirectional heartbeat.  A response to an unsolicited Pong
              * frame is not expected.
              */
         /**
          * A Pong frame MAY be sent unsolicited.  This serves as a
          * unidirectional heartbeat.  A response to an unsolicited Pong
          * frame is not expected.
          */
         case Protocol::TYPE_PONG:
             $this->log('Received unsolicited pong', 'info');
             break;
         case Protocol::TYPE_CLOSE:
             $this->log('Close frame received', 'notice');
             $this->close();
             $this->log('Disconnected', 'info');
             break;
         default:
             throw new ConnectionException('Unhandled payload type');
     }
 }
コード例 #2
0
 /**
  * @param string $payload
  * @dataProvider getValidEncodePayloads
  */
 public function testEncodePayloadReflection($type, $payload)
 {
     $this->payload->encode($payload, Protocol::TYPE_TEXT);
     $this->assertEquals($payload, $this->payload->getPayload(), 'Encode retains payload information');
 }