The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::WebSocket::PMCE::deflate::Server - permessage-deflate for a server

SYNOPSIS

    my $deflate = Net::WebSocket::PMCE::deflate::Server->new( %opts );

    #You’ll probably want Net::WebSocket::Handshake
    #to do this for you, but just in case:
    #$deflate->consume_parameters( @params_kv );

    #OPTIONAL: Inspect $deflate to be sure you’re happy with the setup
    #that the client’s parameters allow.

    #Send this to the client.
    my $handshake = $deflate->create_handshake_object();

    #...and now use this to send/receive messages.
    my $data_obj = $deflate->create_data_object();

DESCRIPTION

The above should describe the workflow sufficiently.

The optional “inspection” step is to ensure that you’re satisfied with the compression parameters, which may be different now from what you gave to the constructor.

For example, if you do this:

    my $deflate = Net::WebSocket::PMCE::deflate::Server->new(
        inflate_max_window_bits => 10,
    );

… and then this has no client_max_window_bits:

    $deflate->consume_parameters( @extn_objs );

… then that means the client doesn’t understand client_max_window_bits, which means we can’t send that parameter. When this happens, $deflate changes to return 15 rather than 10 from its inflate_max_window_bits() method.

In general this should be fine, but if, for some reason, you want to insist that the client compress with no more than 10 window bits, then at this point you can fail the connection.

OBJ->consume_parameters( KEY1 => VALUE1, .. )

Inherited from the base class. The alterations made in response to the different parameters are:

  • <client_no_context_takeover> - Sets the object’s inflate_no_context_takeover flag.

  • <server_no_context_takeover> - Sets the object’s deflate_no_context_takeover flag.

  • <client_max_window_bits> - If given and less than the object’s inflate_max_window_bits option, then that option is reduced to the new value.

  • <server_max_window_bits> - If given and less than the object’s deflate_max_window_bits option, then that option is reduced to the new value.