NAME
Protocol::WebSocket::Fast::Message - WebSocket Message class
DESCRIPTION
The class represents a message received via WebSocket protocol.
You cannot instantiate an object of the class direcly, it can be accessed via Protocol::WebSocket::Fast::MessageIterator or Protocol::WebSocket::Fast::Parser.
You cannot modify Message object, all provided methods are read only.
METHODS
error()
Returns undef if there were no errors during parsing the message.
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.
my $message = $message_iterator->next;
if ($message->error) {
if ($message->error == Protocol::WebSocket::Fast::Error::invalid_opcode) { ... }
elsif ($message->error == Protocol::WebSocket::Fast::Error::max_frame_size) { ... }
else { ... }
}
opcode()
The opcode value for the current message
See constants in Protocol::WebSocket::Fast.
is_control()
True if the message is a control message (consists of single control frame)
payload_length()
Returns unpacked payload size, i.e. if payload was compressed, it will return size of uncompressed payload.
payload()
Returns payload as string
close_code()
If this message is a close message
, returns its close code, see Protocol::WebSocket::Fast for constants.
close_message()
If this message is a close message
, returns message assiciated with the close code.
frame_count()
Returns number of frames in the message
SEE ALSO
Protocol::WebSocket::Fast::Frame
Protocol::WebSocket::Fast::MessageIterator