',
password => 'guest',
)->then(sub {
shift->open_channel->publish(
type => 'application/json'
)
});
=head1 DESCRIPTION
Each Net::Async::AMQP::Channel instance represents a virtual chann
head2 json
Returns a L<JSON::MaybeXS> object, for ->encode and ->decode support. This will load L<JSON::MaybeXS> on first call.
=cut
sub json {
shift->{json} //= do {
eval {
require JSON::May
beXS;
} or die "JSON RPC support requires the JSON::MaybeXS module, which could not be loaded:\n$@";
JSON::MaybeXS->new
}
}
=head2 process_message
Called when there is a message to process. Rec
y ($self, %args) = @_;
$log->debugf("Have message: %s", join ' ', %args);
if(my $code = $self->{json_handler}{$args{type}}) {
# Run the code, and upgrade to a Future if necessary - we accept immed
server L<Net::Async::AMQP::Queue> instance.
=head2 json
Returns a L<JSON::MaybeXS> object, for ->encode and ->decode support. This will load L<JSON::MaybeXS> on first call.
=head2 process_message
everal named parameters:
=head2 configure
Applies configuration:
=over 4
=item * json_handler - defines the JSON handlers for each type
=item * handler - defines default handlers
=back
=head1 I
$f
});
});
}
my $json;
sub json_request {
my ($self, $cmd, $args) = @_;
$json ||= do {
eval {
require JSON::MaybeXS;
} or die "->json_request requires the JSON::MaybeXS module, which
n$@";
$json = JSON::MaybeXS->new;
};
$self->request(
$cmd,
$json->encode($args),
content_type => 'application/json',
)->then(sub {
my $data = shift;
eval {
Future->done($json->decode
($data))
} or do {
Future->fail("Invalid JSON data: " . $data);
}
});
}
sub process_message {
my ($self, %args) = @_;
# $log->infof("Have message: %s", join ' ', %args);
if(my $item = $sel
',
password => 'guest',
)->then(sub {
shift->open_channel->publish(
type => 'application/json'
)
});
=head1 DESCRIPTION
Each Net::Async::AMQP::Channel instance represents a virtual chann