ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/AnyEvent-Porttracker/Porttracker.pm
(Generate patch)

Comparing cvsroot/AnyEvent-Porttracker/Porttracker.pm (file contents):
Revision 1.10 by root, Tue Nov 16 02:07:31 2010 UTC vs.
Revision 1.11 by root, Tue Nov 16 02:09:00 2010 UTC

163 163
164The L<AnyEvent::TLS> object to use. See C<tls>, above. 164The L<AnyEvent::TLS> object to use. See C<tls>, above.
165 165
166=item on_XYZ => $coderef 166=item on_XYZ => $coderef
167 167
168You can specify event callbacks either by subclassing and overriding the 168You can specify event callbacks either by sub-classing and overriding the
169respective methods or by specifying coderefs as key-value pairs when 169respective methods or by specifying code-refs as key-value pairs when
170constructing the object. You add or remove event handlers at any time with 170constructing the object. You add or remove event handlers at any time with
171the C<event> method. 171the C<event> method.
172 172
173=back 173=back
174 174
178 my $class = shift; 178 my $class = shift;
179 179
180 my $self = bless { 180 my $self = bless {
181 id => "a", 181 id => "a",
182 ids => [], 182 ids => [],
183 queue => [], # ininitially queue everything 183 queue => [], # initially queue everything
184 @_, 184 @_,
185 }, $class; 185 }, $class;
186 186
187 { 187 {
188 Scalar::Util::weaken (my $self = $self); 188 Scalar::Util::weaken (my $self = $self);
465 465
466=back 466=back
467 467
468=head1 EVENTS 468=head1 EVENTS
469 469
470AnyEvent::Porttracker conenctions are fully event-driven, and naturally 470AnyEvent::Porttracker connections are fully event-driven, and naturally
471there are a number of events that can occur. All these events have a name 471there are a number of events that can occur. All these events have a name
472starting with C<on_> (example: C<on_login_failure>). 472starting with C<on_> (example: C<on_login_failure>).
473 473
474Programs can catch these events in two ways: either by providing 474Programs can catch these events in two ways: either by providing
475constructor arguments with the event name as key and a coderef as value: 475constructor arguments with the event name as key and a code-ref as value:
476 476
477 my $api = new AnyEvent::Porttracker 477 my $api = new AnyEvent::Porttracker
478 host => ..., 478 host => ...,
479 user => ..., pass => ..., 479 user => ..., pass => ...,
480 on_error => sub { 480 on_error => sub {
482 warn $msg; 482 warn $msg;
483 exit 1; 483 exit 1;
484 }, 484 },
485 ; 485 ;
486 486
487Or by subclassing C<AnyEvent::Porttracker> and overriding methods of the 487Or by sub-classing C<AnyEvent::Porttracker> and overriding methods of the
488same name: 488same name:
489 489
490 package MyClass; 490 package MyClass;
491 491
492 use base AnyEvent::Porttracker; 492 use base AnyEvent::Porttracker;
540 540
541=item on_start_tls_notify $api 541=item on_start_tls_notify $api
542 542
543Called when the server wants to start TLS negotiation. This is used 543Called when the server wants to start TLS negotiation. This is used
544internally and - while it is possible to override it - should not be 544internally and - while it is possible to override it - should not be
545overriden. 545overridden.
546 546
547=item on_event_notify $api, $eventname, @args 547=item on_event_notify $api, $eventname, @args
548 548
549Called when the server broadcasts an event the API object is subscribed 549Called when the server broadcasts an event the API object is subscribed
550to. The default implementation (which should not be overridden) simply 550to. The default implementation (which should not be overridden) simply

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines