GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Protocol::WebSocket::Frame(3) User Contributed Perl Documentation Protocol::WebSocket::Frame(3)

Protocol::WebSocket::Frame - WebSocket Frame

    # 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

Construct or parse a WebSocket frame.

By default built-in "rand" is used, this is not secure, so when Math::Random::Secure is installed it is used instead.

    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).

"buffer" => STR (default: "")
The payload of the frame.
"type" => TYPE_STR (default: "text")
The type of the frame. Accepted values are:

    continuation
    text
    binary
    ping
    pong
    close
    
"opcode" => INT (default: 1)
The opcode of the frame. If "type" field is set to a valid string, this field is ignored.
"fin" => BOOL (default: 1)
"fin" flag of the frame. "fin" flag must be 1 in the ending frame of fragments.
"masked" => BOOL (default: 0)
If set to true, the frame will be masked.
"version" => VERSION_STR (default: 'draft-ietf-hybi-17')
WebSocket protocol version string. See Protocol::WebSocket for valid version strings.

Check if frame is of continuation type.

Check if frame is of text type.

Check if frame is of binary type.

Check if frame is a ping request.

Check if frame is a pong response.

Check if frame is of close type.

    $opcode = $frame->opcode;
    $frame->opcode(8);

Get/set opcode of the frame.

    $masked = $frame->masked;
    $frame->masked(1);

Get/set masking of the frame.

    $frame->append($chunk);

Append a frame chunk.

Beware that this method is destructive. It makes $chunk empty unless $chunk is read-only.

    $frame->append(...);

    $frame->next; # next message

Return the next message as a Perl string (UTF-8 decoded).

Return the next message as is.

Construct a WebSocket message.

The maximum size of the payload. You may set this to 0 or "undef" to disable checking the payload size.
2017-12-12 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.