|
NAMEProtocol::WebSocket::Frame - WebSocket FrameSYNOPSIS# Create frame my $frame = Protocol::WebSocket::Frame->new('123'); $frame->to_bytes; # Parse frames my $frame = Protocol::WebSocket::Frame->new; $frame->append(...); $f->next; # get next message $f->next; # get another next message DESCRIPTIONConstruct or parse a WebSocket frame.RANDOM MASK GENERATIONBy default built-in "rand" is used, this is not secure, so when Math::Random::Secure is installed it is used instead.METHODS"new"Protocol::WebSocket::Frame->new('data'); # same as (buffer => 'data') Protocol::WebSocket::Frame->new(buffer => 'data', type => 'close'); Create a new Protocol::WebSocket::Frame instance. Automatically detect if the passed data is a Perl string (UTF-8 flag) or bytes. When called with more than one arguments, it takes the following named arguments (all of them are optional).
"is_continuation"Check if frame is of continuation type."is_text"Check if frame is of text type."is_binary"Check if frame is of binary type."is_ping"Check if frame is a ping request."is_pong"Check if frame is a pong response."is_close"Check if frame is of close type."opcode"$opcode = $frame->opcode; $frame->opcode(8); Get/set opcode of the frame. "masked"$masked = $frame->masked; $frame->masked(1); Get/set masking of the frame. "append"$frame->append($chunk); Append a frame chunk. Beware that this method is destructive. It makes $chunk empty unless $chunk is read-only. "next"$frame->append(...); $frame->next; # next message Return the next message as a Perl string (UTF-8 decoded). "next_bytes"Return the next message as is."to_bytes"Construct a WebSocket message."max_payload_size"The maximum size of the payload. You may set this to 0 or "undef" to disable checking the payload size.
Visit the GSP FreeBSD Man Page Interface. |