AnyEvent-XMPP
view release on metacpan or search on metacpan
lib/AnyEvent/XMPP/Connection.pm view on Meta::CPAN
package AnyEvent::XMPP::Connection;
use strict;
use AnyEvent;
use AnyEvent::XMPP::Parser;
use AnyEvent::XMPP::Writer;
use AnyEvent::XMPP::Util qw/split_jid join_jid simxml/;
use AnyEvent::XMPP::SimpleConnection;
use AnyEvent::XMPP::Namespaces qw/xmpp_ns/;
use AnyEvent::XMPP::Extendable;
use AnyEvent::XMPP::Error;
use Object::Event;
use Digest::SHA qw/sha1_hex/;
use Encode;
our @ISA = qw/AnyEvent::XMPP::SimpleConnection Object::Event AnyEvent::XMPP::Extendable/;
=head1 NAME
AnyEvent::XMPP::Connection - XML stream that implements the XMPP RFC 3920.
=head1 SYNOPSIS
use AnyEvent::XMPP::Connection;
my $con =
AnyEvent::XMPP::Connection->new (
username => "abc",
domain => "jabber.org",
resource => "AnyEvent::XMPP"
);
$con->reg_cb (stream_ready => sub { print "XMPP stream ready!\n" });
$con->connect; # will do non-blocking connect
=head1 DESCRIPTION
This module represents a XMPP stream as described in RFC 3920. You can issue the basic
XMPP XML stanzas with methods like C<send_iq>, C<send_message> and C<send_presence>.
And receive events with the C<reg_cb> event framework from the connection.
If you need instant messaging stuff please take a look at C<AnyEvent::XMPP::IM::Connection>.
=head1 METHODS
=over 4
=item B<new (%args)>
Following arguments can be passed in C<%args>:
=over 4
=item language => $tag
This should be the language of the human readable contents that
will be transmitted over the stream. The default will be 'en'.
Please look in RFC 3066 how C<$tag> should look like.
=item jid => $jid
This can be used to set the settings C<username>, C<domain>
(and optionally C<resource>) from a C<$jid>.
=item username => $username
This is your C<$username> (the userpart in the JID);
Note: You have to take care that the stringprep profile for
nodes can be applied at: C<$username>. Otherwise the server
might signal an error. See L<AnyEvent::XMPP::Util> for utility functions
to check this.
B<NOTE:> This field has no effect if C<jid> is given!
=item domain => $domain
If you didn't provide a C<jid> (see above) you have to set the
C<username> which you want to connect as (see above) and the
C<$domain> to connect to.
B<NOTE:> This field has no effect if C<jid> is given!
=item resource => $resource
If this argument is given C<$resource> will be passed as desired
resource on resource binding.
Note: You have to take care that the stringprep profile for
resources can be applied at: C<$resource>. Otherwise the server
might signal an error. See L<AnyEvent::XMPP::Util> for utility functions
to check this.
=item host => $host
This parameter specifies the hostname where we are going
to connect to. The default for this is the C<domain> of the C<jid>.
B<NOTE:> To disable DNS SRV lookup you need to specify the port B<number>
( run in 0.996 second using v1.01-cache-2.11-cpan-df04353d9ac )