Protocol::WebSocket::Fast::Frame - WebSocket Frame class
The class represents a frame received via WebSocket protocol.
The Frame object cannot be instantiated direcly, it can be accessed via Protocol::WebSocket::Fast::FrameIterator or Protocol::WebSocket::Fast::Parser.
The Frame object is read-only, i.e. all provided methods are just getters.
Returns undef if there were no errors during parsing the frame.
Otherwise returns an XS::ErrorCode object which represents Perl API for convenient C++ std::error_code subsystem. Possible errors are described in Protocol::WebSocket::Fast::Error and Protocol::HTTP::Error.
std::error_code
my $frame = $frame_iterator->next; if ($frame->error) { if ($frame->error == Protocol::WebSocket::Fast::Error::invalid_opcode) { ... } elsif ($frame->error == Protocol::WebSocket::Fast::Error::max_frame_size) { ... } else { ... } }
The opcode value for the current frame
See constants in Protocol::WebSocket::Fast.
True if the frame is a control frame
True if the frame is final
Returns frame payload length, i.e. size of transferred bytes over network. Might not match the size of actual payload if it was compressed.
Returns payload as a string.
Performance note: as the underhood the payload can be transferred over network in different fragments, it might be uneffective to concantenate all pieces every time on payload access; in other words it is recommended to cache the method.
If this frame is a close frame, returns its close code, see Protocol::WebSocket::Fast for constants.
close frame
If this frame is a close frame, returns its message.
Protocol::WebSocket::Fast
Protocol::WebSocket::Fast::FrameIterator
Protocol::WebSocket::Fast::Message
Protocol::WebSocket::Fast::Parser
rfc6455
To install Protocol::WebSocket::Fast, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Protocol::WebSocket::Fast
CPAN shell
perl -MCPAN -e shell install Protocol::WebSocket::Fast
For more information on module installation, please visit the detailed CPAN module installation guide.