Net::Async::XMPP(3)

πŸ“¦ version 0.003, in alpine 3.24

✨ Net::Async::XMPP ✨

okay so bestie, picture this: an asynchronous XMPP client β€” like, it does its whole chatting thing without ever blocking your event loop, which is the vibe. It's built on top of Protocol::XMPP and IO::Async::Protocol::Stream, and honestly? It ate. πŸ’…

This is the Net::Async::XMPP page from the User Contributed Perl Documentation, and it's giving very much "gateway to the good stuff" β€” the real deets live in the subclasses, but let's get you oriented first. πŸ¦‹


🌸 VERSION 🌸

version 0.002 β€” yes queen, we're on 0.002. Small number, big energy. ✨


πŸŽ€ SYNOPSIS πŸŽ€

okay so here's the whole setup, and ngl it's kind of iconic β€” you make a loop, you make a client, you hand it a bunch of callbacks, you add it to the loop, you log in, you run. Periodt. πŸ‘‘

use IO::Async::Loop;
use Net::Async::XMPP;
my $loop = IO::Async::Loop->new;
my $client = Net::Async::XMPP::Client->new(
       on_message              => sub {
               my ($client, $msg) = @_;
               warn "Message from " . $msg->from . " subject " . $msg->subject . " body " . $msg->body;
               $msg->reply(
                       body => 'Message received: ' . $msg->body
               );
       },
       on_contact_request      => sub {
               my ($client, $contact) = @_;
               warn "Contact request from " . $contact->jid;
       },
       on_presence             => sub {
               my ($client, $contact) = @_;
               warn "Had a presence update from " . $contact->jid;
       },
);
$loop->add($client);
$client->login(
       jid     => 'user@example.com',
       password => $ENV{NET_ASYNC_XMPP_PASSWORD},
);
$loop->run;

so yeah πŸ’– β€” on_message fires and you get the $msg, and you can peek at ->from, ->subject, ->body, and then ->reply(body => ...) right back at them. on_contact_request hands you a $contact and you can warn about ->jid. on_presence does the same presence-update thing. Then $loop->add($client), $client->login(jid => ..., password => ...), and $loop->run. That's it, that's the whole ritual. Notice the password comes from $ENV{NET_ASYNC_XMPP_PASSWORD} β€” keep your secrets in the environment, bestie, not in your source. πŸ™ˆ


🧚 DESCRIPTION 🧚

fr fr, this page is mostly a signpost. If you want the actual details, go look at the Net::Async::XMPP::Client or Net::Async::XMPP::Server subclasses β€” they're the main characters here, and I'm just the group chat pointing you at them. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Tom Molesworth <cpan@entitymodel.com> β€” the one who made it happen. πŸ’œ


🌈 CONTRIBUTORS 🌈

with thanks to the following for contribution β€” genuinely obsessed with these people, no cap:

  • Arthur Axel "fREW" Schmidt for testing, documentation, pointing out some of my mistakes, that sort of thing 😭 (we love a person who catches the oopses)
  • Paul "LeoNerd" Evans for adding Futures to IO::Async (and writing both in the first place) β€” like, literally built the whole foundation, king behaviour πŸ‘‘
  • Matt Trout for testing early versions ⭐

πŸ’€ LICENSE πŸ’€

Copyright Tom Molesworth 2010-2014. Licensed under the same terms as Perl itself.

so yeah, that's the legal bit β€” same terms as Perl itself, periodt. πŸ’…


πŸ’– cute little sign-off: this beauty is perl v5.42.2, dated 2026-02-15, straight from the Net::Async::XMPP(3) page in the User Contributed Perl Documentation. go forth and be asynchronous, bestie. πŸ¦‹βœ¨πŸŒΈ
πŸ“¦ where this page comes from