--- AnyEvent-FCP/FCP.pm 2016/06/12 01:48:05 1.21 +++ AnyEvent-FCP/FCP.pm 2021/09/09 00:49:06 1.28 @@ -20,8 +20,8 @@ This module implements the freenet client protocol version 2.0, as used by freenet 0.7. See L for the earlier freenet 0.5 version. -See L for a -description of what the messages do. +See L for a description of what the +messages do. The module uses L to find a suitable event module. @@ -138,7 +138,7 @@ Invoked on any (fatal) errors, such as unexpected connection close. The callback receives the FCP object and a textual error message. -=item on_failure => $callback->($fcp, $type, $backtrace, $args, $error) +=item on_failure => $callback->($fcp, $type, $args, $backtrace, $error) Invoked when an FCP request fails that didn't have a failure callback. See L for details. @@ -267,13 +267,13 @@ sub fatal { my ($self, $msg) = @_; - $self->{hdl}->shutdown; + $self->{hdl}->push_shutdown if $self->{hdl}; delete $self->{kw}; if ($self->{on_error}) { $self->{on_error}->($self, $msg); } else { - die $msg; + die "AnyEvent::FCP($self->{host}:$self->{port}): $msg"; } } @@ -294,12 +294,6 @@ my $msg = (touc $type) . "\012" . join "", map +(touc $_) . "=$kv{$_}\012", keys %kv; - sub id { - my ($self) = @_; - - - } - if (defined $data) { $msg .= "DataLength=" . (length $data) . "\012" . "Data\012$data"; @@ -427,7 +421,7 @@ $fcp->get_plugin_info_ ($name, $detailed, $cb); -You can thinbk of the underscore as a kind of continuation indicator - the +You can think of the underscore as a kind of continuation indicator - the normal function waits and returns with the data, the C<_> indicates that you pass the continuation yourself, and the continuation will be invoked with the results. @@ -446,16 +440,16 @@ This is a popular choice, but it makes handling errors hard - make sure you never generate protocol errors! -If an C hook exists, it will be invoked with the FCP object, -the request type (the name of the method), a (textual) backtrace as -generated by C, and arrayref containing the arguments from -the original request invocation and the error object from the server, in -this order, e.g.: +In the failure case, if an C hook exists, it will be invoked +with the FCP object, the request type (the name of the method, an arrayref +containing the arguments from the original request invocation, a (textual) +backtrace as generated by C, and the error object from the +server, in this order, e.g.: on_failure => sub { - my ($fcp, $request_type, $backtrace, $orig_args, $error_object) = @_; + my ($fcp, $request_type, $orig_args, $backtrace, $error_object) = @_; - warn "FCP failure ($type), $error_object->{code_description} ($error_object->{extra_description})$backtrace"; + warn "FCP failure ($type @$args), $error_object->{code_description} ($error_object->{extra_description})$backtrace"; exit 1; }, @@ -739,7 +733,7 @@ =item $status = $fcp->remove_request ($identifier[, $global]) -Remove the request with the given isdentifier. Returns true if successful, +Remove the request with the given identifier. Returns true if successful, false on error. =cut @@ -794,7 +788,7 @@ want to read (get) files or write (put) files, respectively. On error, an exception is thrown. Otherwise, C<$can_read> and -C<$can_write> indicate whether you can reaqd or write to freenet via the +C<$can_write> indicate whether you can read or write to freenet via the directory. =cut @@ -925,9 +919,9 @@ To fill this cache with the global queue and keep it updated, call C to subscribe to updates, followed by -C. +C. - $fcp->watch_global_sync_; # do not wait + $fcp->watch_global_; # do not wait $fcp->list_persistent_requests; # wait To get a better idea of what is stored in the cache, here is an example of @@ -1046,7 +1040,7 @@ } # see if the dummy plugin is loaded, to ensure all previous requests have finished. - $fcp->get_plugin_info_sync ("dummy"); + $fcp->get_plugin_info ("dummy"); =head1 SEE ALSO