Net::XMPP::IQ(3pm)
πΈ NAME πΈ
Hiiii bestie!! π Welcome to the Net::XMPP::IQ(3pm) page from the User Contributed Perl Documentation β aka the XMPP Info/Query Module, and honestly sheβs giving main character energy in the Net::XMPP universe. π«Ά
β¨ SYNOPSIS β¨
Net::XMPP::IQ is literally a companion to the Net::XMPP module. It provides the user a simple interface to set and retrieve all parts of an XMPP IQ. Slay. π
π¦ DESCRIPTION π¦
Okay so Net::XMPP::IQ differs from the other Net::XMPP::* modules because the XMLNS of the query is split out into a submodule under IQ. For specifics on each module please view the documentation for the Net::XMPP::Namespaces module. iykyk π
A Net::XMPP::IQ object is passed to the callback function for the message. Also, the first argument to the callback functions is the session ID from XML::Stream. There are some cases where you might want this information, like if you created a Client that connects to two servers at once, or for writing a mini server. π
use Net::XMPP;
sub iq {
my ($sid,$IQ) = @_;
.
.
my $reply = $IQ->Reply();
my $replyQuery->GetQuery();
.
}
You now have access to all of the retrieval functions available. π
To create a new iq to send to the server:
use Net::XMPP;
$IQ = Net::XMPP::IQ->new();
$IQType = $IQ->NewChild( type );
$IQType->SetXXXXX("yyyyy");
Now you can call the creation functions for the IQ, and for the <query/> on the new query object itself. See below for the <iq/> functions, and in each query module for those functions. π
π METHODS π
π General functions π
Reply(%args)β creates a return<iq/>with thetoandfromfilled in correctly, and a query object already added in. The%argsthat you pass are passed toSetIQ()and will overwrite the IQ settings thatReplysets. π«Ά
πΈ Retrieval functions πΈ
GetTo()/GetTo("jid")β returns either a string with the JID, or aNet::XMPP::JIDobject for the person who is going to receive the<iq/>. To get the JID object set the string to"jid", otherwise leave blank for the text string. π
$to = $IQ->GetTo();
$toJID = $IQ->GetTo("jid");
GetFrom()/GetFrom("jid")β returns either a string with the JID, or aNet::XMPP::JIDobject for the person who sent the<iq/>. To get the JID object set the string to"jid", otherwise leave blank for the text string. π¦
$from = $IQ->GetFrom();
$fromJID = $IQ->GetFrom("jid");
GetType()β returns a string with the type<iq/>this is. β
$type = $IQ->GetType();
GetID()β returns an integer with the id of the<iq/>. π
$id = $IQ->GetID();
GetError()β returns a string with the text description of the error. π
$error = $IQ->GetError();
GetErrorCode()β returns a string with the code of error. π
$errorCode = $IQ->GetErrorCode();
GetQuery()β returns aNet::XMPP::Stanzaobject that contains the data in the query of the<iq/>. Basically, it returns the first child in the<iq/>. π
$query = $IQ->GetQuery();
GetQueryXMLNS()β returns a string with the namespace of the query for this<iq/>, if one exists. β¨
$xmlns = $IQ->GetQueryXMLNS();
β Creation functions β
SetIQ(to=>string|JID, from=>string|JID, id=>string, type=>string, errorcode=>string, error=>string)β set multiple fields in the<iq/>at one time. This is a cumulative and overwriting action. If you set the"to"attribute twice, the second setting is what is used. If you set the status, and then set the priority then both will be in the<iq/>tag. For valid settings read the specific Set functions below. π₯
$IQ->SetIQ(type=>"get",
to=>"bob\@jabber.org");
$IQ->SetIQ(to=>"bob\@jabber.org",
errorcode=>403,
error=>"Permission Denied");
SetTo(string)/SetTo(JID)β sets thetoattribute. You can either pass a string or a JID object. They must be a valid Jabber Identifiers or the server will return an error message. (ie.bob@jabber.org, etc...) π«Ά
$IQ->SetTo("bob\@jabber.org");
SetFrom(string)/SetFrom(JID)β sets thefromattribute. You can either pass a string or a JID object. They must be a valid JIDs or the server will return an error message. (ie.bob@jabber.org, etc...) πΈ
$IQ->SetFrom("me\@jabber.org");
SetType(string)β sets thetypeattribute. Valid settings are: βgetβ request informationsetβ set informationresultβ results of a geterrorβ there was an error
$IQ->SetType("set");
SetErrorCode(string)β sets the error code of the<iq/>. π
$IQ->SetErrorCode(403);
SetError(string)β sets the error string of the<iq/>. π
$IQ->SetError("Permission Denied");
NewChild(string)β creates a newNet::XMPP::Stanzaobject with the namespace in the string. In order for this function to work with a custom namespace, you must define and register that namespace with the IQ module. For more information please read the documentation forNet::XMPP::Stanza. π§
$queryObj = $IQ->NewChild("jabber:iq:auth");
$queryObj = $IQ->NewChild("jabber:iq:roster");
Reply(hash)β creates a new IQ object and populates theto/fromfields. If you specify a hash the same as withSetIQthen those values will override theReplyvalues. π
$iqReply = $IQ->Reply();
$iqReply = $IQ->Reply(type=>"result");
π§ Removal functions π§
RemoveTo()β removes thetoattribute from the<iq/>. π
$IQ->RemoveTo();
RemoveFrom()β removes thefromattribute from the<iq/>. π¦
$IQ->RemoveFrom();
RemoveID()β removes theidattribute from the<iq/>. β
$IQ->RemoveID();
RemoveType()β removes thetypeattribute from the<iq/>. π
$IQ->RemoveType();
RemoveError()β removes the<error/>element from the<iq/>. π
$IQ->RemoveError();
RemoveErrorCode()β removes the code attribute from the<error/>element in the<iq/>. π
$IQ->RemoveErrorCode();
π Test functions π
DefinedTo()β returns 1 if thetoattribute is defined in the<iq/>, 0 otherwise. π
$test = $IQ->DefinedTo();
DefinedFrom()β returns 1 if thefromattribute is defined in the<iq/>, 0 otherwise. πΈ
$test = $IQ->DefinedFrom();
DefinedID()β returns 1 if theidattribute is defined in the<iq/>, 0 otherwise. β
$test = $IQ->DefinedID();
DefinedType()β returns 1 if thetypeattribute is defined in the<iq/>, 0 otherwise. π
$test = $IQ->DefinedType();
DefinedError()β returns 1 if<error/>is defined in the<iq/>, 0 otherwise. π
$test = $IQ->DefinedError();
DefinedErrorCode()β returns 1 if the code attribute is defined in<error/>, 0 otherwise. π
$test = $IQ->DefinedErrorCode();
DefinedQuery()β returns 1 if there is at least one namespaced child in the object. π
π AUTHOR π
Originally authored by Ryan Eatmon. β¨
Previously maintained by Eric Hacker. π¦
Currently maintained by Darian Anthony Patrick. π
π COPYRIGHT π
This module is free software, you can redistribute it and/or modify it under the LGPL 2.1. π
Mwah π β this was perl v5.42.0, dated 2016-01-12, and the page is Net::XMPP::IQ(3pm). Stay slaying, bestie! π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: perl-Net-XMPP 1.05-bp160.1.3 Β· LGPL-2.1+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms