AnyEvent-XMPP

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.5 Mon Mar 16 21:13:13 CET 2009
         - added patch for Ext::Pubsub.
         - melo fixed some memleaks.
         - fixed another long time memleak in the parser.

0.4 Sun Feb 15 22:59:38 CET 2009
         - added a $dont_retrieve_vcard to ::Ext::VCard, to
           prevent retrieval when session_ready event comes.
         - implemented support for old-style (tcp port 5223) SSL connections,
           use the old_style_ssl option for ::Connection to enable TLS handshaking
           upon TCP connect.
         - added $message argument to subscription related events. the contents
           comes from the <status> elements in the presence stanza.
         - made special contact for keeping track of the presences of our own
           resources. See ::IM::Roster::get_own_contact() and ::IM::Contact::is_me().
         - minor fixes in ::Ext::MUC.
         - added 'stream_version_override' parameter to ::Connection, mostly
           for testing purposes with ejabberd (to enforce old-jabber-style
           authentication).
         - partially reversed a patch w.r.t. hostname usage for SASL mechanism.

README  view on Meta::CPAN


        Maintenance release. Added a patch from Marcus Dubois for
        Ext::Pubsub. Also fixed some memleaks in AnyEvent::XMPP::Parser.

        Also wanted to note that the next version of AnyEvent::XMPP will
        have an incompatible API. If you are eager to try out the new
        complete rewrite of AnyEvent::XMPP contact me.

    *   0.4

        Minor fixes and feature enhancements: Added old_style_ssl option for
        direct port 5223 SSL connections. Providing 'get_own_contact' for
        keeping track of own resources.

        The AnyEvent::XMPP::Ext::MUC extension was rewritten and provides a
        more sane API now.

        For details consult the Changes file in the distribution.

    *   0.3

lib/AnyEvent/XMPP.pm  view on Meta::CPAN


Maintenance release. Added a patch from Marcus Dubois for Ext::Pubsub.
Also fixed some memleaks in L<AnyEvent::XMPP::Parser>.

Also wanted to note that the next version of AnyEvent::XMPP will have an
incompatible API. If you are eager to try out the new complete rewrite of
AnyEvent::XMPP contact me.

=item * 0.4

Minor fixes and feature enhancements: Added old_style_ssl option for direct
port 5223 SSL connections. Providing 'get_own_contact' for keeping
track of own resources.

The L<AnyEvent::XMPP::Ext::MUC> extension was rewritten and provides a more
sane API now.

For details consult the Changes file in the distribution.

=item * 0.3

lib/AnyEvent/XMPP/Connection.pm  view on Meta::CPAN

=item connect_timeout => $timeout

This sets the connection timeout. If the socket connect takes too long
a C<disconnect> event will be generated with an appropriate error message.
If this argument is not given no timeout is installed for the connects.

=item password => $password

This is the password for the C<username> above.

=item disable_ssl => $bool

If C<$bool> is true no SSL will be used.

=item old_style_ssl => $bool

If C<$bool> is true the TLS handshake will be initiated when the TCP
connection was established. This is useful if you have to connect to
an old Jabber server, with old-style SSL connections on port 5223.

But that practice has been discouraged in XMPP, and a TLS handshake is done
after the XML stream has been established. Only use this option if you know
what you are doing.

=item disable_sasl => $bool

lib/AnyEvent/XMPP/Connection.pm  view on Meta::CPAN

      }
   });


   $self->{iq_id}              = 1;
   $self->{default_iq_timeout} = 60;

   $self->{disconnect_cb} = sub {
      my ($host, $port, $message) = @_;
      delete $self->{authenticated};
      delete $self->{ssl_enabled};
      $self->event (disconnect => $host, $port, $message);
      $self->{disconnect_cb} = sub {};
      delete $self->{writer};
      $self->{parser}->cleanup;
      delete $self->{parser};
   };

   if ($self->{jid}) {
      my ($user, $host, $res) = split_jid ($self->{jid});
      $self->{username} = $user;

lib/AnyEvent/XMPP/Connection.pm  view on Meta::CPAN

=cut

sub connect {
   my ($self) = @_;
   $self->SUPER::connect ($self->{host}, $self->{port}, $self->{connect_timeout});
}

sub connected {
   my ($self) = @_;

   if ($self->{old_style_ssl}) {
      $self->enable_ssl;
   }

   $self->init;
   $self->event (connect => $self->{peer_host}, $self->{peer_port});
}

sub send_buffer_empty {
   my ($self) = @_;
   $self->event ('send_buffer_empty');
}

lib/AnyEvent/XMPP/Connection.pm  view on Meta::CPAN

   $stop and return;

   my $def_ns = $self->default_namespace;

   if ($node->eq (stream => 'features')) {
      $self->event (stream_features => $node);
      $self->{features} = $node;
      $self->handle_stream_features ($node);

   } elsif ($node->eq (tls => 'proceed')) {
      $self->enable_ssl;
      $self->{parser}->init;
      $self->{writer}->init;
      $self->{writer}->send_init_stream (
         $self->{language}, $self->{domain}, $self->{stream_namespace}
      );

   } elsif ($node->eq (tls => 'failure')) {
      $self->event ('tls_error');
      $self->disconnect ('TLS failure on TLS negotiation.');

lib/AnyEvent/XMPP/Connection.pm  view on Meta::CPAN

   my ($self, $node) = @_;
   my @bind  = $node->find_all ([qw/bind bind/]);
   my @tls   = $node->find_all ([qw/tls starttls/]);

   # and yet another weird thingie: in XEP-0077 it's said that
   # the register feature MAY be advertised by the server. That means:
   # it MAY not be advertised even if it is available... so we don't
   # care about it...
   # my @reg   = $node->find_all ([qw/register register/]);

   if (not ($self->{disable_ssl}) && not ($self->{ssl_enabled}) && @tls) {
      $self->{writer}->send_starttls;

   } elsif (not $self->{authenticated}) {
      my $continue = 1;
      $self->event (stream_pre_authentication => \$continue);
      if ($continue) {
         $self->authenticate;
      }

   } elsif (@bind) {

lib/AnyEvent/XMPP/SimpleConnection.pm  view on Meta::CPAN

sub write_data {
   my ($self, $data) = @_;

   $self->{handle}->push_write (encode_utf8 ($data));
   $self->debug_wrote_data (encode_utf8 ($data));
   $self->{handle}->on_drain (sub {
      $self->send_buffer_empty;
   });
}

sub enable_ssl {
   my ($self) = @_;

   $self->{handle}->starttls ('connect');
   $self->{ssl_enabled} = 1;
}

sub disconnect {
   my ($self, $msg) = @_;
   $self->end_sockets;
   $self->{disconnect_cb}->($self->{peer_host}, $self->{peer_port}, $msg);
   $self->remove_all_callbacks;
}

1;

samples/disco_version  view on Meta::CPAN

         if ($j) {
            version_req ($vers, $con, $j);
         } else {
            print "no more jids to query ($out_cnt/$in_cnt)...\n";
            last;
         }
      }
      mkti ($con);
   });
}
$cl->add_account ($jid, $pass);#, undef, undef, { disable_ssl => 1 });
$cl->reg_cb (
   session_ready => sub {
      my ($cl, $acc) = @_;
      $acc->connection->set_default_iq_timeout (300);
      warn "session ready!\n";
      mkti ($acc->connection);
      $cl->unreg_me
   },
   disconnect => sub {
      my ($cl, $acc, $h, $p, $reas) = @_;



( run in 1.017 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )