++ed by:
SKOLYCHEV TEAM

2 PAUSE users
1 non-PAUSE user.

Author image Felipe Gasper
and 1 contributors

NAME

Net::WebSocket::Streamer::Server

SYNOPSIS

    open my $rfh, '<', '/some/big/file';

    my $stream = Net::WebSocket::Streamer::Server->new('binary');

    while ( read $rfh, my $buf, 32768 ) {
        my $chunk = $stream->create_chunk($buf);
        print {$socket} $chunk->to_bytes();
    }

    print {$socket} $stream->create_final(q<>);

DESCRIPTION

The SYNOPSIS pretty well shows it: you can use this module (or its twin, Net::WebSocket::Streamer::Client) to send a WebSocket message without buffering the full contents.

EXTENSION SUPPORT

You can subclass this module to support initial frame types other than text or binary. (Subsequent frames are always continuations.)

You can also set the reserved bytes manually on the individual frames to support extensions that involve those bits.