APNS-Agent
view release on metacpan or search on metacpan
lib/APNS/Agent.pm view on Meta::CPAN
my ($self, $req) = @_;
my $result = {
sent => $self->_sent,
queued => scalar( @{ $self->_queue } ),
};
my $body = encode_json($result);
return [200, [
'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,
t/01_basic.t view on Meta::CPAN
ok 0 <= $diff && $diff < 5, 'expiry ok';
$handle->push_read( chunk => 2, sub {
is($_[1], pack('n', 32), 'token size ok');
$handle->push_read( chunk => 32, sub {
is($_[1], 'd'x32, 'token ok');
$handle->push_read( chunk => 2, sub {
my $payload_length = unpack('n', $_[1]);
$handle->push_read( chunk => $payload_length, sub {
my $payload = $_[1];
my $p = decode_json($payload);
is(length $payload, $payload_length, 'payload length ok');
is $p->{aps}->{alert}, 'ã»ã', 'value of alert';
$cv->send;
});
});
});
});
});
});
});
( run in 0.274 second using v1.01-cache-2.11-cpan-65fba6d93b7 )