#cp.websocket.frame
Implementation of RFC-6455, Section 5
Reads and writes data to and from websocket frame wire protocol data.
#API Overview
Functions - API calls offered directly by the extension
Constructors - API calls which return an object, typically one that offers API methods
Methods - API calls which can only be made on an object returned by a constructor
#API Documentation
#Functions
Signature | cp.websocket.frame.bytesRequired(data) -> number | nil |
Type | Function |
Description | Checks bytes in the data string or buffer . If it contains a valid frame header (everything up to but not including the masking key/payload) it will return the total required bytes for a valid frame, otherwise it will return nil . |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | src/extensions/cp/websocket/frame.lua line 166 |
Signature | cp.websocket.frame.fromBuffer(buff) -> result<{frame:frame, bytes:number}> |
Type | Function |
Description | Reads a Websocket Frame from the provided cp.buffer of binary data. |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | src/extensions/cp/websocket/frame.lua line 234 |
Signature | cp.websocket.frame.fromBytes(buff) -> result<{frame:frame, bytes:number}> |
Type | Function |
Description | Reads a Websocket Frame from the provided cp.buffer of binary data. |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | src/extensions/cp/websocket/frame.lua line 215 |
Signature | cp.websocket.frame.fromHex(value, spacer) -> frame, number | nil |
Type | Function |
Description | Convenience function for converting "XX XX" strings to a binary string, then parsing it into a frame. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/websocket/frame.lua line 297 |
Signature | cp.websocket.frame.isValid(data) -> number |
Type | Function |
Description | Checks bytes in the data string or buffer contains a valid frame . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/websocket/frame.lua line 192 |
#Constructors
Signature | cp.websocket.frame.new(final, opcode, mask, payloadData) -> cp.websocket.frame |
Type | Constructor |
Description | Creates a new frame instance. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/websocket/frame.lua line 311 |
#Methods
Signature | cp.websocket.frame:isControlFrame() -> boolean |
Type | Method |
Description | Checks if the frame has a control frame opcode. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/websocket/frame.lua line 353 |
Signature | cp.websocket.frame:isNonControlFrame() -> boolean |
Type | Method |
Description | Checks if the frame has a non-control frame opcode. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/websocket/frame.lua line 340 |
Signature | cp.websocket.frame:toBytes() -> string |
Type | Method |
Description | Converts the frame to its byte string form. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/websocket/frame.lua line 373 |