The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::WebSocket::Defragmenter

SYNOPSIS

    my $defragger = Net::WebSocket::Defragmenter->new(
        parser => $parser_obj,  #i.e., isa Net::WebSocket::Parser

        #Optional; these two receive the Net::WebSocket::Frame object.
        on_control_frame => sub { ... },
        on_data_frame => sub { ... },

        #Optional; receives a type string and a human-readable message.
        #An exception is thrown after this callback runs.
        on_protocol_error => sub { ... },
    );

    my $msg_or_undef = $defragger->get_next_message();

DESCRIPTION

You ordinarily shouldn’t instantiate this class because Net::WebSocket::Endpoint already uses it.

This class implements WebSocket’s defragmentation logic. It’s mostly meant for internal use but is documented for cases where Net::WebSocket::Endpoint may not be usable or desirable.

METHODS

CLASS->new( %OPTS )

See SYNOPSIS above.

OBJ->get_next_message()

Reads a frame from parser.

Returns a Net::WebSocket::Message object if there is a message ready to return; otherwise returns undef.

An exception (Net::WebSocket::X) is thrown on fragmentation errors.