AnyEvent-MSN
view release on metacpan or search on metacpan
lib/AnyEvent/MSN.pm view on Meta::CPAN
clearer => '_reset_tid',
builder => '_build_tid',
traits => ['Counter'],
handles => {'_inc_tid' => 'inc'}
);
sub _build_tid {0}
after tid => sub { shift->_inc_tid }; # Auto inc
has ping_timer => (is => 'ro',
isa => 'Ref', # AE::timer
writer => '_set_ping_timer'
);
# Server configuration
has policies => (
is => 'bare',
isa => 'HashRef',
clearer => '_reset_policies',
writer => '_set_policies',
traits => ['Hash'],
handles => {_add_policy => 'set',
_del_policy => 'delete',
policy => 'get',
policies => 'kv' # XXX - Really?
}
);
# SOAP
has SSOsites => (
is => 'ro', # Single Sign On
isa => 'ArrayRef[ArrayRef]',
traits => ['Array'],
default => sub {
[['http://Passport.NET/tb', ''],
['messengerclear.live.com', 'MBI_KEY_OLD'],
['messenger.msn.com', '?id=507'],
['messengersecure.live.com', 'MBI_SSL'],
['contacts.msn.com', 'MBI'],
['storage.msn.com', 'MBI'],
['sup.live.com', 'MBI']
];
}
);
has auth_tokens => (is => 'bare',
isa => 'HashRef',
clearer => '_reset_auth_tokens',
writer => '_set_auth_tokens',
traits => ['Hash'],
handles => {_add_auth_token => 'set',
_del_auth_token => 'delete',
auth_token => 'get',
auth_tokens => 'kv'
}
);
has contacts => (is => 'ro',
isa => 'HashRef',
clearer => '_reset_contacts',
writer => '_set_contacts',
traits => ['Hash'],
);
# Simple callbacks
has 'on_' . $_ => (
traits => ['Code'],
is => 'ro',
isa => 'CodeRef',
default => sub {
sub {1}
},
handles => {'_trigger_' . $_ => 'execute_method'},
)
for qw[
im nudge
error fatal_error connect
addressbook_update
buddylist_update
user_notification
create_circle
];
has connected => (
is => 'ro',
isa => 'Bool',
traits => ['Bool'],
default => 0,
handles => {_set_connected => 'set', _unset_connected => 'unset'}
);
has redirect => (
is => 'ro',
isa => 'Str',
predicate => '_has_redirect',
writer => '_set_redirect',
clearer => '_reset_redirect' # XXX - Currently unused internally
);
# Auto connect
sub BUILD {
my ($s, $p) = @_;
return if $p->{no_autoconnect};
$s->connect;
}
sub connect {
my $s = shift;
$s->_unset_connected;
$s->_set_handle(
AnyEvent::Handle->new(
connect => [$s->host, $s->port],
on_connect => sub {
# Get ready to read data from server
$s->handle->push_read(
'AnyEvent::MSN::Protocol' => sub {
my ($cmd, $tid, @data) = @_;
my $method = $s->can('_handle_packet_' . lc($cmd));
$method ||= sub {
$s->_trigger_error(
'Unhandled command type: ' . $cmd,
0);
};
if ($cmd =~ m[^(?:GCF|MSG|NFY|NOT|SDG|UBX|PUT)$])
{ # payload types
$s->handle->unshift_read(
( run in 1.140 second using v1.01-cache-2.11-cpan-140bd7fdf52 )