AnyEven...nection(3)
π NAME π
okay so welcome to the manual page for AnyEvent::XMPP::IM::Connection β yes, the header shortens it to AnyEven...nection(3), but bestie itβs literally the same icon π
. This module is an "XML" stream that implements the XMPP RFC 3921, and itβs giving instant messaging main character energy.
β¨ SYNOPSIS β¨
use AnyEvent::XMPP::Connection;
my $con = AnyEvent::XMPP::Connection->new;
πΈ DESCRIPTION πΈ
This module represents a XMPP instant messaging connection and implements RFC 3921. No cap.
Itβs a subclass of "AnyEvent::XMPP::Connection" and inherits all its methods. So yeah, things like "reg_cb" and the stanza sending routines are yours for free, periodt.
For the extra events you can register, look below in the EVENTS section β thatβs where the fun stuff lives π¦.
π METHODS π
new (%args)
This is the constructor, bestie. It takes the same arguments as the constructor of AnyEvent::XMPP::Connection, plus a few extra ones:
dont_retrieve_roster => $boolβ set this to a true value if no roster should be requested when the connection is established. You can still retrieve the roster later if you want, using the"retrieve_roster"method. Okay but listen: the internal roster will be set even if this option is active, and even presences will be stored in there. The catch? The"get_contacts"method on the roster object wonβt return anything, because there are no roster items. Thatβs the vibe check π.initial_presence => $priorityβ this sets whether the initial presence should be sent.$priorityshould be the priority of the initial presence. The default value for the initial presence$priorityis10. And if you pass an undefined value as$priority, no initial presence will be sent! none. zero. not happening. π
retrieve_roster ($cb)
This method initiates a roster request. If you set "dont_retrieve_roster" when creating this connection, then no roster was retrieved β and this method is how you do that little retrieval later. The coderef in $cb will be called after the roster was retrieved.
The first argument of the callback in $cb will be the roster, and the second will be a AnyEvent::XMPP::Error::IQ object when an error occurred while retrieving the roster. Good to know, fr fr.
get_roster
Returns the roster object of type AnyEvent::XMPP::IM::Roster. Slay.
π EVENTS π
These additional events can be registered on with "reg_cb":
In the following events, $roster is the AnyEvent::XMPP::IM::Roster object you get by calling "get_roster".
NODE: The first argument to each callback is always theAnyEvent::XMPP::IM::Connectionobject itself. Also seeObject::Eventfor more information about registering callbacks.
session_ready
This event is generated when the session has been fully established and can be used to send around messages and other stuff. Itβs giving ready-to-chat energy β¨.
session_error => $error
If an error happened during establishment of the session, this event will be generated. $error will be an AnyEvent::XMPP::Error::IQ error object. Not iconic, but informative π«Ά.
roster_update => $roster, $contacts
This event is emitted when a roster update has been received. $contacts is an array reference of AnyEvent::XMPP::IM::Contact objects which have changed. If a contact was removed, it will return 'remove' when you call the "subscription" method on it.
The first time this event is sent is when the roster was received for the first time. First-roster moment, iykyk.
roster_error => $error
If an error happened during retrieval of the roster, this event will be generated. $error will be an AnyEvent::XMPP::Error::IQ error object.
presence_update => $roster, $contact, $old_presence, $new_presence
This event is emitted when the presence of a contact has changed. $contact is the AnyEvent::XMPP::IM::Contact object which presence status has changed. $old_presence is a AnyEvent::XMPP::IM::Presence object which represents the presence prior to the change. $new_presence is a AnyEvent::XMPP::IM::Presence object which represents the presence after the change. The new presence might be undef if the new presence is 'unavailable'. π
presence_error => $error
This event is emitted when a presence stanza error was received. $error will be an AnyEvent::XMPP::Error::Presence error object.
message => $msg
This event is emitted when a message was received. $msg is a AnyEvent::XMPP::IM::Message object. Inbox behavior, literally.
message_error => $error
This event is emitted when a message stanza error was received. $error will be an AnyEvent::XMPP::Error::Message error object.
contact_request_subscribe => $roster, $contact, $message
This event is generated when $contact wants to subscribe to your presence.
If you want to accept or decline the request, call the "send_subscribed" method of AnyEvent::XMPP::IM::Contact or the "send_unsubscribed" method of AnyEvent::XMPP::IM::Contact on $contact.
If you want to start a mutual subscription, you have to call "send_subscribe" AFTER you accepted or declined with "send_subscribed"/"send_unsubscribed". Calling it in the opposite order gets some servers confused! So do not do that, bestie π.
If a "status" element was transmitted with the subscription, its contents will be in $message. Which is usually a text written from the one who requests subscription.
contact_subscribed => $roster, $contact, $message
This event is generated when $contact subscribed you to his presence successfully.
If a "status" element was transmitted with the subscribed presence, its contents will be in $message.
contact_did_unsubscribe => $roster, $contact, $message
This event is generated when $contact unsubscribes from your presence.
If you want to unsubscribe from him, call the "send_unsubscribe" method of AnyEvent::XMPP::IM::Contact on $contact.
If a "status" element was transmitted with the unsubscription, its contents will be in $message. Which is usually a text written from the one who unsubscribes.
contact_unsubscribed => $roster, $contact, $message
This event is generated when $contact unsubscribed you from his presence.
If you want to unsubscribe him from your presence, call the "send_unsubscribed" method of AnyEvent::XMPP::IM::Contact on $contact.
If a "status" element was transmitted with the unsubscription, its contents will be in $message.
π AUTHOR π
Robin Redeker, "<elmex at ta-sa.org>", JID: "<elmex at jabber.org>" β iconic author behavior, periodt.
π COPYRIGHT & LICENSE π
Copyright 2007, 2008 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay thatβs the whole vibe π the footer says this came from perl v5.42.2, dated 2026-02-15, and the manual name is AnyEven...nection(3). bye bestie, go send some stanzas π¦β¨
π¦ where this page comes from
- alpine 3.24: perl-anyevent-xmpp-doc 0.55-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms