… | |
… | |
224 | if ($self->{tls}) { |
224 | if ($self->{tls}) { |
225 | require Net::SSLeay; |
225 | require Net::SSLeay; |
226 | $self->starttls (delete $self->{tls}, delete $self->{tls_ctx}); |
226 | $self->starttls (delete $self->{tls}, delete $self->{tls_ctx}); |
227 | } |
227 | } |
228 | |
228 | |
229 | # $self->on_eof (delete $self->{on_eof} ) if $self->{on_eof}; # nop |
|
|
230 | # $self->on_error (delete $self->{on_error}) if $self->{on_error}; # nop |
|
|
231 | # $self->on_read (delete $self->{on_read} ) if $self->{on_read}; # nop |
|
|
232 | $self->on_drain (delete $self->{on_drain}) if $self->{on_drain}; |
|
|
233 | |
|
|
234 | $self->{_activity} = AnyEvent->now; |
229 | $self->{_activity} = AnyEvent->now; |
235 | $self->_timeout; |
230 | $self->_timeout; |
236 | |
231 | |
237 | $self->start_read; |
232 | $self->on_drain (delete $self->{on_drain}) if $self->{on_drain}; |
|
|
233 | $self->on_read (delete $self->{on_read} ) if $self->{on_read}; |
238 | |
234 | |
239 | $self |
235 | $self |
240 | } |
236 | } |
241 | |
237 | |
242 | sub _shutdown { |
238 | sub _shutdown { |
… | |
… | |
686 | |
682 | |
687 | sub on_read { |
683 | sub on_read { |
688 | my ($self, $cb) = @_; |
684 | my ($self, $cb) = @_; |
689 | |
685 | |
690 | $self->{on_read} = $cb; |
686 | $self->{on_read} = $cb; |
|
|
687 | $self->_drain_rbuf if $cb; |
691 | } |
688 | } |
692 | |
689 | |
693 | =item $handle->rbuf |
690 | =item $handle->rbuf |
694 | |
691 | |
695 | Returns the read buffer (as a modifiable lvalue). |
692 | Returns the read buffer (as a modifiable lvalue). |
… | |
… | |
1033 | =item $handle->stop_read |
1030 | =item $handle->stop_read |
1034 | |
1031 | |
1035 | =item $handle->start_read |
1032 | =item $handle->start_read |
1036 | |
1033 | |
1037 | In rare cases you actually do not want to read anything from the |
1034 | In rare cases you actually do not want to read anything from the |
1038 | socket. In this case you can call C<stop_read>. Neither C<on_read> no |
1035 | socket. In this case you can call C<stop_read>. Neither C<on_read> nor |
1039 | any queued callbacks will be executed then. To start reading again, call |
1036 | any queued callbacks will be executed then. To start reading again, call |
1040 | C<start_read>. |
1037 | C<start_read>. |
1041 | |
1038 | |
1042 | Note that AnyEvent::Handle will automatically C<start_read> for you when |
1039 | Note that AnyEvent::Handle will automatically C<start_read> for you when |
1043 | you change the C<on_read> callback or push/unshift a read callback, and it |
1040 | you change the C<on_read> callback or push/unshift a read callback, and it |