| 1 | package Net::WebSocket::Streamer::Server; | ||
| 2 | |||
| 3 | =encoding utf-8 | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Net::WebSocket::Streamer::Server | ||
| 8 | |||
| 9 | =head1 SYNOPSIS | ||
| 10 | |||
| 11 | open my $rfh, '<', '/some/big/file'; | ||
| 12 | |||
| 13 | my $stream = Net::WebSocket::Streamer::Server->new('binary'); | ||
| 14 | |||
| 15 | while ( read $rfh, my $buf, 32768 ) { | ||
| 16 | my $chunk = $stream->create_chunk($buf); | ||
| 17 | print {$socket} $chunk->to_bytes(); | ||
| 18 | } | ||
| 19 | |||
| 20 | print {$socket} $stream->create_final(q<>); | ||
| 21 | |||
| 22 | =head1 DESCRIPTION | ||
| 23 | |||
| 24 | The SYNOPSIS pretty well shows it: you can use this module | ||
| 25 | (or its twin, C<Net::WebSocket::Streamer::Client>) to send a WebSocket | ||
| 26 | message without buffering the full contents. | ||
| 27 | |||
| 28 | =head1 EXTENSION SUPPORT | ||
| 29 | |||
| 30 | You can subclass this module to support initial frame types other than | ||
| 31 | text or binary. (Subsequent frames are always continuations.) | ||
| 32 | |||
| 33 | You can also set the reserved bytes manually on the individual frames | ||
| 34 | to support extensions that involve those bits. | ||
| 35 | |||
| 36 | =cut | ||
| 37 | |||
| 38 | use strict; | ||
| 39 | use warnings; | ||
| 40 | |||
| 41 | use parent qw( | ||
| 42 | Net::WebSocket::Streamer | ||
| 43 | Net::WebSocket::Masker::Server | ||
| 44 | ); | ||
| 45 | |||
| 46 | 1; |