AnyEvent::XMPP::IM::Contact(3) User Contributed Perl Documentation AnyEvent::XMPP::IM::Contact(3)

AnyEvent::XMPP::IM::Contact - Instant messaging roster contact

my $con = AnyEvent::XMPP::IM::Connection->new (...);
my $ro  = $con->roster;
if (my $c = $ro->get_contact ('')) {
   $c->make_message ()->add_body ("Hello there!")->send;

This module represents a class for contact objects which populate a roster (AnyEvent::XMPP::IM::Roster.

There are two types of 'contacts' that are managed by this class. The first are contacts that are on the users roster, and the second are contacts that are not on the users roster.

To find our whether this is a contact which is actually available as roster item in the users roster, you should consult the "is_on_roster" method (see below).

Another special kind of contact is the contact which stands for ourself and is mostly only used for keeping track of our own presences and resources. But note that even if the "is_me" method returns true, the "is_on_roster" method might also return a true value, in case we have a roster item of ourself on the roster (which might happen in rare cases :).

You can get an instance of this class only by calling the "get_contact" function on a roster object.

This method updates a contact. If the request is finished it will call $cb. If it resulted in an error the first argument of that callback will be a AnyEvent::XMPP::Error::IQ object.

The %upd hash should have one of the following keys and defines what parts of the contact to update:

Updates the name of the contact. $name = '' erases the contact.
Adds the contact to the groups in the array reference $groups.
Removes the contact from the groups in the array reference $groups.
This sets the groups of the contact. $groups should be an array reference of the groups.
This method sends this contact a subscription request.
This method accepts a contact's subscription request.
This method sends this contact a unsubscription request.
This method sends this contact a unsubscription request which unsubscribes ones own presence from him (he wont get any further presence from us).
This method wants a AnyEvent::XMPP::Node in $item which should be a roster item received from the server. The method will update the contact accordingly and return it self.
This method updates the presence of contacts on the roster. $presence must be a AnyEvent::XMPP::Node object and should be a presence packet.
This method returns a presence of this contact if it is available. The return value is an instance of AnyEvent::XMPP::IM::Presence or undef if no such presence exists.
Returns all presences of this contact in form of AnyEvent::XMPP::IM::Presence objects.
Returns the presence with the highest priority.
Returns the list of groups (strings) this contact is in.
Returns the bare JID of this contact.
Returns the (nick)name of this contact.
Returns 1 if this is a contact that is officially on the roster and not just a contact we've received presence information for.
Returns a true value when this contacts stands for ourself and is only used for receiving presences of our own resources.
Returns the subscription state of this contact, which can be one of:
'none', 'to', 'from', 'both'

If the contact isn't on the roster anymore this method returns:

Returns 'subscribe' if we asked this contact for subscription.
Returns true if this contact has a pending subscription. That means: the contact has to aknowledge the subscription.
Returns the nickname of this contact (or, if none is set in the roster, it returns the node part of the JID)
This method returns a AnyEvent::XMPP::IM::Message object with the to field set to this contacts JID.

%args are further arguments for the message constructor.

Robin Redeker, "<elmex at>", JID: "<elmex at>"

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.

2023-07-25 perl v5.38.0