APNS-Agent
view release on metacpan or search on metacpan
# NAME
APNS::Agent - agent server for APNS
# SYNOPSIS
use APNS::Agent;
my $agent = APNS::Agent->new(
certificate => '/path/to/certificate',
private_key => '/path/to/private_key',
);
$agent->run;
# DESCRIPTION
APNS::Agent is agent server for APNS. It is also backend class of [apns-agent](http://search.cpan.org/perldoc?apns-agent).
This module provides consistent connection to APNS and cares reconnection. It utilizes
[AnyEvent::APNS](http://search.cpan.org/perldoc?AnyEvent::APNS) internally.
lib/APNS/Agent.pm view on Meta::CPAN
use Encode qw/decode_utf8/;
use JSON::XS;
use Log::Minimal;
use Plack::Request;
use Router::Boom::Method;
use Class::Accessor::Lite::Lazy 0.03 (
new => 1,
ro => [qw/
certificate
private_key
sandbox
debug_port
/],
ro_lazy => {
on_error_response => sub {
sub {
my $self = shift;
my %d = %{$_[0]};
warnf "identifier:%s\tstate:%s\ttoken:%s", $d{identifier}, $d{state}, $d{token} || '';
}
lib/APNS/Agent.pm view on Meta::CPAN
'Content-Type' => 'application/json; charset=utf-8',
'Content-Length' => length($body),
], [$body]];
}
sub _build_apns {
my $self = shift;
AnyEvent::APNS->new(
certificate => $self->certificate,
private_key => $self->private_key,
sandbox => $self->sandbox,
on_error => sub {
my ($handle, $fatal, $message) = @_;
my $t; $t = AnyEvent->timer(
after => 0,
interval => 10,
cb => sub {
undef $t;
infof "event:reconnect";
lib/APNS/Agent.pm view on Meta::CPAN
=head1 NAME
APNS::Agent - agent server for APNS
=head1 SYNOPSIS
use APNS::Agent;
my $agent = APNS::Agent->new(
certificate => '/path/to/certificate',
private_key => '/path/to/private_key',
);
$agent->run;
=head1 DESCRIPTION
APNS::Agent is agent server for APNS. It is also backend class of L<apns-agent>.
This module provides consistent connection to APNS and cares reconnection. It utilizes
L<AnyEvent::APNS> internally.
t/01_basic.t view on Meta::CPAN
});
});
});
};
local $Log::Minimal::LOG_LEVEL = "NONE";
my $apns_agent = APNS::Agent->new(
sandbox => 1,
certificate => 'dummy',
private_key => 'dummy',
debug_port => $apns_port,
);
test_psgi
app => $apns_agent->to_app,
client => sub {
my $cb = shift;
ok !$apns_agent->__apns->connected;
my $req = POST 'http://localhost', [
( run in 0.284 second using v1.01-cache-2.11-cpan-4d50c553e7e )