Interprets parsed frames from the peer, and packs and writes frames.
TODO: Multiplex by RSV.
TODO: Stream writing.
| Protected Properties | |
| string | $buffer = '' | 
| The message buffer for data frames.  More... | |
| WebSocketClient | $client | 
| int null | $continue | 
| Resume opCode for the CONTINUATIONhandler.  More... | |
| int | $fragmentSize = 128 * 1024 | 
| Max outgoing fragment size.  More... | |
| int | $maxLength = 10 * 1024 * 1024 | 
| Maximum inbound message length (complete payload).  More... | |
| FrameReader | $reader | 
| bool | $stream = false | 
| Whether binary I/O should bypass buffers.  More... | |
| Public Methods | |
| __construct (WebSocketClient $client) | |
| int | getFragmentSize () | 
| int | getMaxLength () | 
| bool | isStream () | 
| void | onFrame (Frame $frame) | 
| Called by WebSocketClient when a complete frame has been received.  More... | |
| void | onReadable () | 
| Uses FrameReader to read frames and passes them off to onFrame().  More... | |
| $this | setFragmentSize (int $bytes) | 
| $this | setMaxLength (int $bytes) | 
| $this | setStream (bool $stream) | 
| void | write (int $opCode, string $payload) | 
| Sends a complete message to the peer, fragmenting if needed.  More... | |
| void | writeBinary (string $payload) | 
| void | writeClose (int $code=Frame::CLOSE_NORMAL, string $reason='') | 
| void | writePing (string $payload='') | 
| void | writePong (string $payload='') | 
| void | writeText (string $payload) | 
| Protected Methods | |
| void | onBinary (Frame $frame) | 
| Progressively receives BINARYdata into the buffer until the payload is complete.  More... | |
| void | onClose (Frame $frame) | 
| When a CLOSEframe is received.  More... | |
| void | onContinuation (Frame $frame) | 
| When a CONTINUATIONframe (data fragment) is received.  More... | |
| void | onControl (Frame $frame) | 
| When a control frame is received.  More... | |
| void | onData (Frame $frame) | 
| When an initial data frame (not CONTINUATION) is received.  More... | |
| void | onData_CheckLength (Frame $frame) | 
| Validates the message length, but only when the buffer is in use.  More... | |
| void | onPing (Frame $frame) | 
| When a PINGis received.  More... | |
| void | onPong (Frame $frame) | 
| When a PONGis received.  More... | |
| void | onText (Frame $frame) | 
| Progressively receives TEXTdata until the payload is complete.  More... | |
| void | writeFrame (bool $final, int $opCode, string $payload) | 
| Writes a single frame.  More... | |
| 
 | protected | 
The message buffer for data frames.
| 
 | protected | 
Resume opCode for the CONTINUATION handler. 
| 
 | protected | 
Max outgoing fragment size.
Each browser has its own standard, so this is generalized.
Defaults to 128 KiB.
| 
 | protected | 
Maximum inbound message length (complete payload).
Defaults to 10 MiB.
| 
 | protected | 
Whether binary I/O should bypass buffers.
| __construct | ( | WebSocketClient | $client | ) | 
| WebSocketClient | $client | 
| int getFragmentSize | ( | ) | 
| int getMaxLength | ( | ) | 
| bool isStream | ( | ) | 
| 
 | protected | 
Progressively receives BINARY data into the buffer until the payload is complete. 
Passes the complete payload up to WebSocketClient::onBinary()
When $stream is true, this bypasses the buffer.
| Frame | $frame | 
| WebSocketError | 
| 
 | protected | 
When a CLOSE frame is received. 
Calls WebSocketClient::onClose()
https://tools.ietf.org/html/rfc6455#section-5.5.1
If an endpoint receives a Close frame and did not previously send a Close frame, the endpoint MUST send a Close frame in response. (When sending a Close frame in response, the endpoint typically echos the status code it received.)
| Frame | $frame | 
| 
 | protected | 
When a CONTINUATION frame (data fragment) is received. 
| Frame | $frame | 
| WebSocketError | 
| 
 | protected | 
When a control frame is received.
https://tools.ietf.org/html/rfc6455#section-5.4
Control frames (see Section 5.5) MAY be injected in the middle of a fragmented message.
| Frame | $frame | 
| 
 | protected | 
When an initial data frame (not CONTINUATION) is received. 
| Frame | $frame | 
| 
 | protected | 
Validates the message length, but only when the buffer is in use.
| Frame | $frame | 
| WebSocketError | 
| void onFrame | ( | Frame | $frame | ) | 
Called by WebSocketClient when a complete frame has been received.
Delegates to the other handler methods using the program logic outlined in the RFC.
Eventually calls back to the WebSocketClient when payloads are complete.
| Frame | $frame | 
| 
 | protected | 
| 
 | protected | 
| void onReadable | ( | ) | 
Uses FrameReader to read frames and passes them off to onFrame().
| 
 | protected | 
Progressively receives TEXT data until the payload is complete. 
Validates the complete payload as UTF-8 and passes it up to WebSocketClient::onText()
| Frame | $frame | 
| WebSocketError | 
| $this setFragmentSize | ( | int | $bytes | ) | 
| int | $bytes | 
| $this setMaxLength | ( | int | $bytes | ) | 
| int | $bytes | 
| $this setStream | ( | bool | $stream | ) | 
| bool | $stream | 
| void write | ( | int | $opCode, | 
| string | $payload | ||
| ) | 
Sends a complete message to the peer, fragmenting if needed.
| int | $opCode | |
| string | $payload | 
| void writeBinary | ( | string | $payload | ) | 
| string | $payload | 
| void writeClose | ( | int | $code = Frame::CLOSE_NORMAL, | 
| string | $reason = '' | ||
| ) | 
| int | $code | |
| string | $reason | 
| 
 | protected | 
Writes a single frame.
| bool | $final | |
| int | $opCode | |
| string | $payload | 
| void writePing | ( | string | $payload = '' | ) | 
| string | $payload | 
| void writePong | ( | string | $payload = '' | ) | 
| string | $payload | 
| void writeText | ( | string | $payload | ) | 
| string | $payload |