Protocol::WebSocket::Frame - WebSocket Frame
# Create frame my $frame = Protocol::WebSocket::Frame->new('123'); $frame->to_string; # \x00123\xff # Parse frames my $frame = Protocol::WebSocket::Frame->new; $frame->append("123\x00foo\xff56\x00bar\xff789"); $f->next; # foo $f->next; # bar
Construct or parse a WebSocket frame.
new
Create a new Protocol::WebSocket::Frame instance. Automatically detect if the passed data is a Perl string or bytes.
append
$frame->append("\x00foo"); $frame->append("bar\xff");
Append a frame chunk.
next
$frame->append("\x00foo"); $frame->append("\xff\x00bar\xff"); $frame->next; # foo $frame->next; # bar
Return the next frame as a Perl string.
next_bytes
Return the next frame as a UTF-8 encoded string.
to_string
my $frame = Protocol::WebSocket::Frame->new('foo'); $frame->to_string; # \x00foo\xff
Construct a WebSocket frame as a Perl string.
to_bytes
Construct a WebSocket frame as a UTF-8 encoded string.
To install Protocol::WebSocket, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Protocol::WebSocket
CPAN shell
perl -MCPAN -e shell install Protocol::WebSocket
For more information on module installation, please visit the detailed CPAN module installation guide.