APNS-Agent
view release on metacpan or search on metacpan
lib/APNS/Agent.pm view on Meta::CPAN
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} || '';
}
},
disconnect_interval => sub { 60 },
lib/APNS/Agent.pm view on Meta::CPAN
on_error_response => sub {
my ($identifier, $state) = @_;
my $data = $self->_sent_cache->get($identifier) || {};
$self->on_error_response->($self, {
identifier => $identifier,
state => $state,
token => $data->{token},
payload => $data->{payload},
});
},
($self->debug_port ? (debug_port => $self->debug_port) : ()),
);
}
sub _apns {
my $self = shift;
my $apns = $self->__apns;
$apns->connect unless $apns->connected;
$apns;
}
lib/APNS/Agent.pm view on Meta::CPAN
require Hash::Rename;
my $p = Getopt::Long::Parser->new(
config => [qw/posix_default no_ignore_case auto_help pass_through bundling/]
);
$p->getoptionsfromarray(\@argv, \my %opt, qw/
certificate=s
private-key=s
disconnect-interval=i
sandbox!
debug-port=i
/) or Pod::Usage::pod2usage();
Pod::Usage::pod2usage() if !$opt{certificate} || !$opt{'private-key'};
Hash::Rename::hash_rename(\%opt, code => sub {tr/-/_/});
(\%opt, \@argv);
}
sub run {
my $self = shift;
my %args = @_ == 1 ? %{$_[0]} : @_;
script/apns-agent view on Meta::CPAN
__END__
=head1 SYNOPSIS
% apns-agent --certificate=/path/to/certificate --private-key=/path/to/private
Options:
--certificate|s path to certificate (Required)
--private-key|s path to private key (Required)
--disconnect-interval=i disconnect interval (Default: 60)
--sandbox sandbox or not (Default: disable)
--debug-port debug port number (Optional)
=head1 DESCRIPTION
L<APNS::Agent> launcher
=head1 SEE ALSO
L<APNS::Agent>
=head1 AUTHORS
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', [
token => unpack("H*", 'd'x32),
( run in 0.554 second using v1.01-cache-2.11-cpan-49f99fa48dc )