Wrench\Payload\Payload::getPayload PHP Method

getPayload() public method

public getPayload ( ) : string
return string
    public function getPayload()
    {
        $this->buffer = '';
        foreach ($this->frames as $frame) {
            $this->buffer .= $frame->getFramePayload();
        }
        return $this->buffer;
    }

Usage Example

Example #1
0
 /**
  * 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');
     }
 }
All Usage Examples Of Wrench\Payload\Payload::getPayload