| 1 | package Net::WebSocket::Base::ReadString; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Net::WebSocket::X (); | ||
| 7 | |||
| 8 | sub new { | ||
| 9 | my ($class, $str_sr) = @_; | ||
| 10 | |||
| 11 | return bless { _sr => $str_sr }, $class; | ||
| 12 | } | ||
| 13 | |||
| 14 | sub _read { | ||
| 15 | my ($self, $len) = @_; | ||
| 16 | |||
| 17 | die "Useless zero read!" if $len == 0; | ||
| 18 | |||
| 19 | return substr( ${ $self->{'_sr'} }, 0, $len, q<> ); | ||
| 20 | } | ||
| 21 | |||
| 22 | 1; |