Devristo\Phpws\Framing\WebSocketFrame::create PHP Method

create() public static method

public static create ( $type, $data = null )
    public static function create($type, $data = null)
    {
        $o = new self();
        $o->FIN = true;
        $o->payloadData = $data;
        $o->payloadLength = $data != null ? strlen($data) : 0;
        $o->setType($type);
        return $o;
    }

Usage Example

Example #1
0
 function testMasking()
 {
     $input = "Hello World!";
     $frame = WebSocketFrame::create(WebSocketOpcode::TextFrame, $input);
     $frame->setMasked(true);
     $client = new WebSocket("wss://127.0.0.1:12345/echo/");
     $client->open();
     $client->sendFrame($frame);
     $msg = $client->readMessage();
     $client->close();
     $this->assertEquals($input, $frame->getData());
     $this->assertEquals(false, $msg->getFrames()[0]->isMasked());
 }
All Usage Examples Of Devristo\Phpws\Framing\WebSocketFrame::create