| 1 |
elmex |
1.1 |
package Net::XMPP2::Client; |
| 2 |
|
|
use strict; |
| 3 |
|
|
use AnyEvent; |
| 4 |
|
|
use IO::Socket::INET; |
| 5 |
|
|
use Net::XMPP2::Parser; |
| 6 |
|
|
use Net::XMPP2::Writer; |
| 7 |
|
|
use Net::XMPP2::Util; |
| 8 |
|
|
use Net::XMPP2::Event; |
| 9 |
|
|
use Net::XMPP2::SimpleConnection; |
| 10 |
|
|
use Net::XMPP2::Namespaces qw/xmpp_ns/; |
| 11 |
|
|
use Net::DNS; |
| 12 |
|
|
|
| 13 |
|
|
our @ISA = qw/Net::XMPP2::Event/; |
| 14 |
|
|
|
| 15 |
|
|
=head1 NAME |
| 16 |
|
|
|
| 17 |
|
|
Net::XMPP2::Client - A XMPP Client abstraction |
| 18 |
|
|
|
| 19 |
|
|
=head1 SYNOPSIS |
| 20 |
|
|
|
| 21 |
|
|
use Net::XMPP2::Client; |
| 22 |
|
|
use AnyEvent; |
| 23 |
|
|
|
| 24 |
|
|
my $j = AnyEvent->condvar; |
| 25 |
|
|
|
| 26 |
|
|
my $cl = Net::XMPP2::Client->new; |
| 27 |
|
|
$cl->start; |
| 28 |
|
|
|
| 29 |
|
|
$j->wait; |
| 30 |
|
|
|
| 31 |
|
|
=head1 DESCRIPTION |
| 32 |
|
|
|
| 33 |
|
|
This module tries to implement a straight forward and easy to |
| 34 |
|
|
use API to communicate with XMPP entities. L<Net::XMPP2::Client> |
| 35 |
|
|
handles connections and timeouts and all such stuff for you. |
| 36 |
|
|
|
| 37 |
|
|
For more flexibility please have a look at L<Net::XMPP2::Connection> |
| 38 |
|
|
and L<Net::XMPP2::IM::Connection>, they allow you to control what |
| 39 |
|
|
and how something is being sent more precisely. |
| 40 |
|
|
|
| 41 |
|
|
=head1 METHODS |
| 42 |
|
|
|
| 43 |
|
|
=head2 new (%args) |
| 44 |
|
|
|
| 45 |
|
|
Following arguments can be passed in C<%args>: |
| 46 |
|
|
|
| 47 |
|
|
=over 4 |
| 48 |
|
|
|
| 49 |
|
|
=back |
| 50 |
|
|
|
| 51 |
|
|
=cut |
| 52 |
|
|
|
| 53 |
|
|
sub new { |
| 54 |
|
|
my $this = shift; |
| 55 |
|
|
my $class = ref($this) || $this; |
| 56 |
|
|
my $self = { @_ }; |
| 57 |
|
|
bless $self, $class; |
| 58 |
|
|
|
| 59 |
|
|
return $self; |
| 60 |
|
|
} |
| 61 |
|
|
|
| 62 |
|
|
=head1 EVENTS |
| 63 |
|
|
|
| 64 |
|
|
These events can be registered on with C<reg_cb>: |
| 65 |
|
|
|
| 66 |
|
|
=over 4 |
| 67 |
|
|
|
| 68 |
|
|
=item iq_get_request_xml => $node, $handled_ref |
| 69 |
|
|
|
| 70 |
|
|
These events are sent when an iq request stanza of type 'get' or 'set' is received. |
| 71 |
|
|
C<$type> will either be 'get' or 'set' and C<$node> will be the L<Net::XMPP2::Node> |
| 72 |
|
|
object of the iq tag. |
| 73 |
|
|
|
| 74 |
|
|
If C<$$handled_ref> is true an event handler should not handle this message anymore. |
| 75 |
|
|
|
| 76 |
|
|
If one of the event handlers handled this message the scalar pointed at by |
| 77 |
|
|
the reference in C<$handled_ref> should be set to 1 true value. If C<$$handled_ref> |
| 78 |
|
|
is still false after all event handlers were executed an error iq will be generated. |
| 79 |
|
|
|
| 80 |
|
|
=back |
| 81 |
|
|
|
| 82 |
|
|
=head1 AUTHOR |
| 83 |
|
|
|
| 84 |
|
|
Robin Redeker, C<< <elmex at ta-sa.org> >> |
| 85 |
|
|
|
| 86 |
|
|
=head1 COPYRIGHT & LICENSE |
| 87 |
|
|
|
| 88 |
|
|
Copyright 2007 Robin Redeker, all rights reserved. |
| 89 |
|
|
|
| 90 |
|
|
This program is free software; you can redistribute it and/or modify it |
| 91 |
|
|
under the same terms as Perl itself. |
| 92 |
|
|
|
| 93 |
|
|
=cut |
| 94 |
|
|
|
| 95 |
|
|
1; # End of Net::XMPP2::Client |