Net::Ja...Protocol(3)
πΈ Net::Jabber::Protocol πΈ
okay bestie, so this is Net::Jabber::Protocol(3) β straight out of the User Contributed Perl Documentation corner of the universe π. Yes, the title is abbreviated in the header (Net::Ja...Protocol(3)) but the real name is the full thing, and we're about to get into it.
β¨ NAME β¨
Net::Jabber::Protocol β the Jabber Protocol Library π¦ (yes, that Jabber, the instant-messaging one, and this module is the whole vibe)
π SYNOPSIS π
Net::Jabber::Protocol is a module that gives a developer easy access to the Jabber Instant Messaging protocol π
. It hands high level functions to the Net::Jabber Client, Component, and Server objects. And the way these functions show up in those modules? Automatically, through AUTOLOAD and delegates β¨. You don't have to do anything, they're just there, like a good bestie.
π DESCRIPTION π
Protocol.pm is out here trying to give you enough high level APIs and automation of the low level APIs that writing a Jabber Client/Transport in Perl is trivial π β like, actually trivial. And for the people who love to dig around down low? You can absolutely do that too, no gatekeeping. Those functions are covered in the documentation for each module, so go read those if that's your vibe π«Ά.
Net::Jabber::Protocol provides functions to:
- login
- send and receive messages
- set personal information
- create a new user account
- manage the roster
- disconnect
And here's the gorgeous part: you can use all or none of the functions. There is no requirement. Pick and choose, build your own little stack, it's giving main character energy π.
For more information on how the details for how Net::Jabber is written, please see the help for Net::Jabber itself.
For more information on writing a Client, see Net::Jabber::Client.
For more information on writing a Transport, see Net::Jabber::Transport.
π¦ Modes π¦
Several of the functions take a mode argument that lets you specify how the function should behave. This is the vibe check of the whole module, so pay attention π:
blockβ send the packet with an ID, and then block until an answer comes back. You can optionally specify a timeout so that you do not block forever. (please use the timeout, bestie, don't just sit there π)nonblockβ send the packet with an ID, but then return that ID and control to the master program.Net::Jabberis still tracking this packet, so you must use theCheckIDfunction to tell when it comes in. (and yeah, the docs are literally like "this might not be very useful..." π so take that as you will)passthruβ send the packet with an ID, but do NOT register it withNet::Jabber, then return the ID. This is useful when combined with theXPathfunction because you can register a one shot function tied to the ID you get back. chef's kiss combo, fr fr π€
π₯ Basic Functions π₯
okay so first you gotta get your connection going. here's how, from Net::Jabber::Client:
use Net::Jabber qw( Client );
$Con = new Net::Jabber::Client(); # From
$status = $Con->Connect(hostname=>"jabber.org"); # Net::Jabber::Client
or, if Component is more your thing:
use Net::Jabber qw( Component );
$Con = new Net::Jabber::Component(); #
$status = $Con->Connect(hostname=>"jabber.org", # From
secret=>"bob"); # Net::Jabber::Component
and for callback setup, go peek at Net::XMPP::Protocol:
#
# For callback setup, see Net::XMPP::Protocol
#
then you can flex your info like this:
$Con->Info(name=>"Jarl",
version=>"v0.6000");
(that's you, saying hi, telling everyone who you are and what version you're on β iconic behavior honestly π)
π§ ID Functions π§
these are your send-with-an-ID girlies. every one of these hands you back an ID you can hang onto:
$id = $Con->SendWithID($sendObj);
$id = $Con->SendWithID("<tag>XML</tag>");
$receiveObj = $Con->SendAndReceiveWithID($sendObj);
$receiveObj = $Con->SendAndReceiveWithID($sendObj,
10);
$receiveObj = $Con->SendAndReceiveWithID("<tag>XML</tag>");
$receiveObj = $Con->SendAndReceiveWithID("<tag>XML</tag>",
5);
$yesno = $Con->ReceivedID($id);
$receiveObj = $Con->GetID($id);
$receiveObj = $Con->WaitForID($id);
$receiveObj = $Con->WaitForID($id,
20);
see how the numbers just show up there? those are timeouts, and SendAndReceiveWithID / WaitForID both take them optionally. ReceivedID gives you a yes/no. GetID and WaitForID give you the actual object back. slay π
β IQ Functions β
this is the big umbrella heading, and everything below lives under it. IQ functions, but make it a whole aesthetic π.
π Agents Functions π
%agents = $Con->AgentsGet();
%agents = $Con->AgentsGet(to=>"transport.jabber.org");
that's it, that's the whole thing β ask with no args for everything, or point it at a specific to πΈ
π Browse Functions π
%hash = $Con->BrowseRequest(jid=>"jabber.org");
%hash = $Con->BrowseRequest(jid=>"jabber.org",
timeout=>10);
$id = $Con->BrowseRequest(jid=>"jabber.org",
mode=>"nonblock");
$id = $Con->BrowseRequest(jid=>"jabber.org",
mode=>"passthru");
default vibe gives you back a %hash. add a timeout if you don't want to wait forever. or go mode=>"nonblock" / mode=>"passthru" and take the $id instead β¨
π¦ Browse DB Functions π¦
$Con->BrowseDBDelete("jabber.org");
$Con->BrowseDBDelete(Net::Jabber::JID);
$presence = $Con->BrowseDBQuery(jid=>"bob\@jabber.org");
$presence = $Con->BrowseDBQuery(jid=>Net::Jabber::JID);
$presence = $Con->BrowseDBQuery(jid=>"users.jabber.org",
timeout=>10);
$presence = $Con->BrowseDBQuery(jid=>"conference.jabber.org",
refresh=>1);
BrowseDBDelete takes either a plain string or a Net::Jabber::JID. BrowseDBQuery hands you back a $presence, and it takes jid, an optional timeout, and a refresh flag π«Ά β note the \@ in there, escape it, don't get caught out π
π Bystreams Functions π
(yes, that's the heading name, we're keeping it exactly as it is, no notes π
%hash = $Con->ByteStreamsProxyRequest(jid=>"proxy.server");
%hash = $Con->ByteStreamsProxyRequest(jid=>"proxy.server",
timeout=>10);
$id = $Con->ByteStreamsProxyRequest(jid=>"proxy.server",
mode=>"nonblock");
$id = $Con->ByteStreamsProxyRequest(jid=>"proxy.server",
mode=>"passthru");
%hash = $Con->ByteStreamsProxyParse($query);
$status = $Con->ByteStreamsProxyActivate(sid=>"stream_id",
jid=>"proxy.server");
$status = $Con->ByteStreamsProxyActivate(sid=>"stream_id",
jid=>"proxy.server",
timeout=>10);
$id = $Con->ByteStreamsProxyActivate(sid=>"stream_id",
jid=>"proxy.server",
mode=>"nonblock");
$id = $Con->ByteStreamsProxyActivate(sid=>"stream_id",
jid=>"proxy.server",
mode=>"passthru");
$jid = $Con->ByteStreamsOffer(sid=>"stream_id",
streamhosts=>[{jid=>"jid",
host=>"host",
port=>"port",
zeroconf=>"zero",
},
...
],
jid=>"bob\@jabber.org");
$jid = $Con->ByteStreamsOffer(sid=>"stream_id",
streamhosts=>[{},{},...],
jid=>"bob\@jabber.org",
timeout=>10);
$id = $Con->ByteStreamsOffer(sid=>"stream_id",
streamhosts=>[{},{},...],
jid=>"bob\@jabber.org",
mode=>"nonblock");
$id = $Con->ByteStreamsOffer(sid=>"stream_id",
streamhosts=>[{},{},...],
jid=>"bob\@jabber.org",
mode=>"passthru");
okay so ByteStreamsProxyRequest = give me a %hash (or an $id with a mode, plus optional timeout). ByteStreamsProxyParse takes a $query and hands back a %hash. ByteStreamsProxyActivate takes sid + jid and gives you a $status, or an $id in nonblock/passthru, and yes it takes timeout too. ByteStreamsOffer takes sid, streamhosts (an arrayref of hashrefs with jid, host, port, zeroconf keys β ... means more of them, keep adding bestie), and jid, and gives you a $jid back β or an $id with a mode, and timeout is available there as well π
β¨
heads up: the alignment in those examples is straight from the original docs, quirks and all β copy the commands, not the spacing π
π§ Disco Functions π§
%hash = $Con->DiscoInfoRequest(jid=>"jabber.org");
%hash = $Con->DiscoInfoRequest(jid=>"jabber.org",
node=>"node...");
%hash = $Con->DiscoInfoRequest(jid=>"jabber.org",
node=>"node...",
timeout=>10);
$id = $Con->DiscoInfoRequest(jid=>"jabber.org",
mode=>"nonblock");
$id = $Con->DiscoInfoRequest(jid=>"jabber.org",
node=>"node...",
mode=>"nonblock");
$id = $Con->DiscoInfoRequest(jid=>"jabber.org",
mode=>"passthru");
$id = $Con->DiscoInfoRequest(jid=>"jabber.org",
node=>"node...",
mode=>"passthru");
%hash = $Con->DiscoInfoParse($query);
%hash = $Con->DiscoItemsRequest(jid=>"jabber.org");
%hash = $Con->DiscoItemsRequest(jid=>"jabber.org",
timeout=>10);
$id = $Con->DiscoItemsRequest(jid=>"jabber.org",
mode=>"nonblock");
$id = $Con->DiscoItemsRequest(jid=>"jabber.org",
mode=>"passthru");
%hash = $Con->DiscoItemsParse($query);
DiscoInfoRequest takes jid, an optional node, an optional timeout, and the usual mode options. DiscoInfoParse turns a $query into a %hash. DiscoItemsRequest takes jid + optional timeout (or a mode), and DiscoItemsParse turns a $query into a %hash too πβ¨
πΈ Feature Negotiation Functions πΈ
%hash = $Con->FeatureNegRequest(jid=>"jabber.org",
features=>{ feat1=>["opt1","opt2",...],
feat2=>["optA","optB",...]
}
);
%hash = $Con->FeatureNegRequest(jid=>"jabber.org",
features=>{ ... },
timeout=>10);
$id = $Con->FeatureNegRequest(jid=>"jabber.org",
features=>{ ... },
mode=>"nonblock");
$id = $Con->FeatureNegRequest(jid=>"jabber.org",
features=>{ ... },
mode=>"passthru");
my $query = $self->FeatureNegQuery(\{ ... });
$iq->AddQuery($query);
%hash = $Con->FeatureNegParse($query);
so FeatureNegRequest wants a jid and a features hashref where each feature key maps to an arrayref of its options β feat1 gets "opt1", "opt2", ..., feat2 gets "optA", "optB", ... β and yes, timeout and mode are available like everywhere else. then there's FeatureNegQuery(\{ ... }) which gives you a $query you can $iq->AddQuery($query), and FeatureNegParse($query) to get your %hash back π
π File Transfer Functions π
$method = $Con->FileTransferOffer(jid=>"bob\@jabber.org",
sid=>"stream_id",
filename=>"/path/to/file",
methods=>["http://jabber.org/protocol/si/profile/bytestreams",
"jabber:iq:oob",
...
]
);
$method = $Con->FileTransferOffer(jid=>"bob\@jabber.org",
sid=>"stream_id",
filename=>"/path/to/file",
methods=>\@methods,
timeout=>"10");
$id = $Con->FileTransferOffer(jid=>"bob\@jabber.org",
sid=>"stream_id",
filename=>"/path/to/file",
methods=>\@methods,
mode=>"nonblock");
$id = $Con->FileTransferOffer(jid=>"bob\@jabber.org",
sid=>"stream_id",
filename=>"/path/to/file",
methods=>\@methods,
mode=>"passthru");
FileTransferOffer takes jid, sid, filename, and methods. methods can be an inline arrayref with things like "http://jabber.org/protocol/si/profile/bytestreams", "jabber:iq:oob", ... β or you can pass \@methods. it hands you a $method back, or an $id if you go nonblock/passthru, and timeout is right there too (as "10", a string, in the example β copy it exactly, bestie π«Ά) π₯
β Last Functions β
$Con->LastQuery();
$Con->LastQuery(to=>"bob@jabber.org");
%result = $Con->LastQuery(mode=>"block");
%result = $Con->LastQuery(to=>"bob@jabber.org",
mode=>"block");
LastQuery can be called bare, or with a to, or with mode=>"block" β and %result comes back in the block examples. note there's no backslash on that bob@jabber.org here, that's exactly how it's written, don't @ me ππ
More LastQuery flex β same to=>"bob@jabber.org", same mode=>"block", same timeout=>10:
%result = $Con->LastQuery(to=>"bob@jabber.org",
mode=>"block",
timeout=>10);
%result = $Con->LastQuery(mode=>"block",
timeout=>10);
$Con->LastSend(to=>"bob@jabber.org");
$seconds = $Con->LastActivity();
π¬ Multi-User Chat Functions
Joining a room is literally the easiest slay. Basic join first, then the password-protected version:
$Con->MUCJoin(room=>"jabber",
server=>"conference.jabber.org",
nick=>"nick");
$Con->MUCJoin(room=>"jabber",
server=>"conference.jabber.org",
nick=>"nick",
password=>"secret");
πͺͺ Register Functions
Registering a user? RegisterSendData takes the target host and a little bundle of identity fields. No cap:
@result = $Con->RegisterSendData("users.jabber.org",
first=>"Bob",
last=>"Smith",
nick=>"bob",
email=>"foo@bar.net");
π RPC Functions
RPC time π«Ά β encode, parse, call, respond, and set callbacks. All the shapes are below, exactly as they appear:
$query = $Con->RPCEncode(type=>"methodCall",
methodName=>"methodName",
params=>[param,param,...]);
$query = $Con->RPCEncode(type=>"methodResponse",
params=>[param,param,...]);
$query = $Con->RPCEncode(type=>"methodResponse",
faultCode=>4,
faultString=>"Too many params");
@response = $Con->RPCParse($iq);
@response = $Con->RPCCall(to=>"dataHouse.jabber.org",
methodname=>"numUsers",
params=>[ param,param,... ]
);
$Con->RPCResponse(to=>"you\@jabber.org",
params=>[ param,param,... ]);
$Con->RPCResponse(to=>"you\@jabber.org",
faultCode=>"4",
faultString=>"Too many parameters"
);
$Con->RPCSetCallBacks(myMethodA=>\&methoda,
myMethodB=>\&do_somthing,
etc...
);
π Search Functions
Search is giving directory energy: request fields, send a search, or send data straight to a service:
%fields = $Con->SearchRequest();
%fields = $Con->SearchRequest(to=>"users.jabber.org");
%fields = $Con->SearchRequest(to=>"users.jabber.org",
timeout=>10);
$Con->SearchSend(to=>"somewhere",
name=>"",
first=>"Bob",
last=>"",
nick=>"bob",
email=>"",
key=>"some key");
$Con->SearchSendData("users.jabber.org",
first=>"Bob",
last=>"",
nick=>"bob",
email=>"");
β° Time Functions
Time queries: fire one off, or ask for a blocking %result:
$Con->TimeQuery();
$Con->TimeQuery(to=>"bob@jabber.org");
%result = $Con->TimeQuery(mode=>"block");
%result = $Con->TimeQuery(to=>"bob@jabber.org",
mode=>"block");
$Con->TimeSend(to=>"bob@jabber.org");
π·οΈ Version Functions
Version queries: same deal β fire-and-forget or blocking %result. And yes, VersionSend carries name, ver, and os:
$Con->VersionQuery();
$Con->VersionQuery(to=>"bob@jabber.org");
%result = $Con->VersionQuery(mode=>"block");
%result = $Con->VersionQuery(to=>"bob@jabber.org",
mode=>"block");
$Con->VersionSend(to=>"bob@jabber.org",
name=>"Net::Jabber",
ver=>"1.0a",
os=>"Perl");
π§ METHODS π§
π§Έ Basic Functions
Stash your identity so Net::Jabber can auto-reply to some packets for you and save you some work:
Info(name=>string,
version=>string)
β οΈ NOTE: this requires that you use theSetIQCallBacksmethodology and not theSetCallBacksfor<iq/>packets. That distinction is lowkey important, bestie.
π‘ IQ Functions
π΅οΈ Agents Functions
β οΈ Deprecated in favor of Disco β this section is legacy, so donβt build new stuff on it. The details stay because we donβt erase lore. π
AgentsGet
AgentsGet(to=>string,
AgentsGet()
This takes all of the information and builds a Net::Jabber::IQ::Agents packet. It then sends that packet either to the server, or to the specified transport, with an ID, and waits for that ID to return. Then it looks in the resulting packet and builds a hash that contains the values of the agent list. The hash is laid out like this β and yes, the jid is the key that distinguishes the various agents:
$hash{<JID>}->{order} = 4
->{name} = "ICQ Transport"
->{transport} = "ICQ #"
->{description} = "ICQ..blah.."
->{service} = "icq"
->{register} = 1
->{search} = 1
etc...
The order field determines the order that it came from the server in⦠in case you care. For more info on the valid fields, see the Net::Jabber::Query jabber:iq:agent namespace.
π§ Browse Functions
β οΈ Deprecated in favor of Disco β iconic relic behavior, but still deprecated. Donβt act brand new about it.
BrowseRequest
BrowseRequest(jid=>string,
mode=>string,
timeout=>int)
This sends a jabber:iq:browse request to the jid passed as an argument. It returns a hash with the resulting tree if mode is set to "block":
$browse{'category'} = "conference"
$browse{'children'}->[0]
$browse{'children'}->[1]
$browse{'children'}->[11]
$browse{'jid'} = "conference.jabber.org"
$browse{'name'} = "Jabber.org Conferencing Center"
$browse{'ns'}->[0]
$browse{'ns'}->[1]
$browse{'type'} = "public"
The ns array is an array of the namespaces that this jid supports. The children array points to hashes of this form, and represent the fact that they can be browsed to.
See MODES above for using the mode and timeout.
ποΈ Browse DB Functions
BrowseDBDelete
BrowseDBDelete(string|Net::Jabber::JID)
Deletes this JIDβs browse data from the DB.
BrowseDBQuery
BrowseDBQuery(jid=>string | NJ::JID,
timeout=>integer,
refresh=>0|1)
Returns the browse data for the requested JID. If the DB does not contain the data for the JID, then it attempts to fetch the data via BrowseRequest(). The timeout is passed to the BrowseRequest() call, and refresh tells the DB to request the data, even if it already has some.
π Bytestreams Functions
ByteStreamsProxyRequest
ByteStreamsProxyRequest(jid=>string,
mode=>string,
timeout=>int)
Sends a bytestreams request to the jid passed as an argument. It returns an array ref with the resulting tree if mode is set to "block".
See ByteStreamsProxyParse for the format of the resulting tree.
See MODES above for using the mode and timeout.
ByteStreamsProxyParse
ByteStreamsProxyParse(Net::Jabber::Query)
Parses the query and returns an array ref to the resulting tree:
$host[0]->{jid} = "bytestreams1.proxy.server";
$host[0]->{host} = "proxy1.server";
$host[0]->{port} = "5006";
$host[1]->{jid} = "bytestreams2.proxy.server";
$host[1]->{host} = "proxy2.server";
$host[1]->{port} = "5007";
...
ByteStreamsProxyActivate
ByteStreamsProxyActivate(jid=>string,
sid=>string,
mode=>string,
timeout=>int)
Sends a bytestreams activate to the jid passed as an argument. If mode is set to "block", it returns 1 if the proxy activated, and undef if it did not.
sid is the stream id that is being used to talk about this stream.
See MODES above for using the mode and timeout.
ByteStreamsOffer
ByteStreamsOffer(jid=>string,
sid=>string,
streamhosts=>arrayref,
mode=>string,
timeout=>int)
Sends a bytestreams offer to the jid passed as an argument. If mode is set to "block", it returns the jid of the streamhost that the user selected.
streamhosts is the same format as the array ref returned from ByteStreamsProxyParse.
See MODES above for using the mode and timeout.
β¨ Disco Functions β¨
DiscoInfoRequest(jid=>string, node=>string, mode=>string, timeout=>int)β sends a disco#info request to the jid you pass in, and to the node too if you specified one. If mode is set to"block"you get a hash back with the resulting tree, bestie. π
Wanna know what that tree looks like? Peek at DiscoInfoParse, it's literally right there.
And for the whole mode + timeout situation, scroll up to MODES above, iykyk.
DiscoInfoParse(Net::Jabber::Query)β parses the query and hands you back a hash ref to the resulting tree, like this:
$info{identity}->[0]->{category} = "groupchat";
$info{identity}->[0]->{name} = "Public Chatrooms";
$info{identity}->[0]->{type} = "public";
$info{identity}->[1]->{category} = "groupchat";
$info{identity}->[1]->{name} = "Private Chatrooms";
$info{identity}->[1]->{type} = "private";
$info{feature}->{http://jabber.org/protocol/disco#info} = 1;
$info{feature}->{http://jabber.org/protocol/muc#admin} = 1;
DiscoItemsRequest(jid=>string, mode=>string, timeout=>int)β fires off a disco#items request to the jid you passed in. If mode is"block", congrats, you get a hash with the resulting tree. π
The format of that tree? That's DiscoItemsParse's whole thing.
Mode + timeout deets live up in MODES above. Go look, fr fr.
DiscoItemsParse(Net::Jabber::Query)β parses the query and returns a hash ref to the resulting tree, which looks like:
$items{jid}->{node} = name;
$items{"proxy.server"}->{""} = "Bytestream Proxy Server";
$items{"conf.server"}->{"public"} = "Public Chatrooms";
$items{"conf.server"}->{"private"} = "Private Chatrooms";
πΈ Feature Negotiation Functions πΈ
FeatureNegRequest(jid=>string, features=>hash ref, mode=>string, timeout=>int)β sends a feature negotiation to the jid you passed in, using the features you specified. If mode is"block"you get a hash with the resulting tree back. Obsessed. π
Curious about the format of that features hash ref? Run, don't walk, to DiscoInfoQuery.
For the resulting tree's format, check DiscoInfoParse.
And mode + timeout? MODES above, babe. Always MODES.
FeatureNegParse(Net::Jabber::Query)β parses the query and returns a hash ref to the resulting tree:
$features->{feat1} = ["opt1","opt2",...];
$features->{feat2} = ["optA","optB",...];
....
But if this is a result, it's giving something different:
$features->{feat1} = "opt2";
$features->{feat2} = "optA";
....
FeatureNeqQuery(hash ref)β takes a hash ref and turns it into a feature negotiation query that you canAddQueryinto your packet. The hash ref format goes like this:
$features->{feat1} = ["opt1","opt2",...];
$features->{feat2} = ["optA","optB",...];
....
π¦ File Transfer Functions π¦
FileTransferOffer(jid=>string, sid=>string, filename=>string, mode=>string, timeout=>int)β sends a file transfer stream initiation to the jid you passed in. Returns the method if the user accepts,undefif the user declines β but only when mode is set to"block", okay? π
Mode and timeout usage? Say it with me: MODES above. π
β Last Functions β
LastQuery(to=>string, mode=>string, timeout=>int)/LastQuery()β asks the jid you specified for its last activity. Iftois blank, then it queries the server instead. If mode is"block"you get a hash back with the various items set:
$last{seconds} - Seconds since activity
$last{message} - Message for activity
Mode and timeout? You already know β MODES above. π«
LastSend(to=>string, hash)β sends the specified last to the specified jid. That hash is the seconds and message, exactly like the Net::Jabber::Query man page shows.LastActivity()β returns the number of seconds since the user's last activity. That's it, that's the whole vibe check. π
π Multi-User Chat Functions π
MUCJoin(room=>string, server=>string, nick=>string, password=>string)β sends the appropriate MUC protocol to join the specified room with the specified nick. Go be the main character in that group chat. π
π Register Functions π
RegisterSendData(string|JID, hash)β takes the contents of the hash and builds ajabebr:x:datareturn packet, which it sends in aNet::Jabber::Queryjabber:iq:registernamespace packet. The first argument is the JID to send the packet to. This function returns an array that looks like this:
[ type , message ]
If type is "ok" then registration ate and left no crumbs β successful! Otherwise message contains a little more detail about the error. π
π₯ RPC Functions π₯
RPCParse(IQ object)β returns an array. The first argument tells you the status:"ok"or"fault". The second argument is an array if it's"ok", or a hash if it's"fault".RPCCall(to=>jid|string, methodName=>string, params=>array, mode=>string, timeout=>int)β takes themethodNameandparams, builds the RPC call, and sends it to the specified address. Returns the data described above fromRPCParse.
Mode and timeout β yeah, MODES above. π
RPCResponse(to=>jid|string, params=>array, faultCode=>int, faultString=>string)β generates a response back to the caller. If any part offaultis specified, then fault wins. No competition, fault just takes it. π
Note: to make sure you get the correct type for a param sent back, you can specify the type by prepending it to the value:
"i4:5" or "int:5"
"boolean:0"
"string:56"
"double:5.0"
"datetime:20020415T11:11:11"
"base64:...."
RPCSetCallBacks(method=>function, method=>function, etc...)β sets the callback functions for the specified methods. The method comes from the<methodName/>and is case sensitive, so don't get cute with capitalisation. The single arguemnt is a ref to an array that contains the<params/>. The function you write should return one of two things:
["ok", [...] ]
The [...] is a list of the <params/> you want to return. Or:
["fault", {faultCode=>1,
faultString=>...} ]
If you set the function to undef, then the method is removed from the list. Bye bestie. π«Ά
π§ Search Functions π§
SearchRequest(to=>string, mode=>string, timeout=>int)/SearchRequest()β sends an<iq/>request to the specified server/transport, and if nothing's specified it sends to the current active server instead. The function returns a hash containing the required fields. Here's an example of that hash:
$hash{fields} - The raw fields from
the iq:register. To
be used if there is
no x:data in the
packet.
$hash{instructions} - How to fill out
the form.
$hash{form} - The new dynamic forms.
Inside $hash{form}, the fields that are present are the required fields the server needs.
Mode and timeout? One last time for the people in the back: MODES above. π
SearchSend(to=>string|JID, hash)β takes the contents of the hash and passes it to theSetSearchfunction in theNet::Jabber::Queryjabber:iq:searchnamespace. And then it sends the packet. Slay. β¨SearchSendData(string|JID, hash)β takes everything chillin' in the hash and builds ajabber:x:datareturn packet, then sends it inside aNet::Jabber::Queryjabber:iq:searchnamespace packet. The first argument is the JID you're sending to. (Tiny note: the original page spells the namespacejabebr:x:dataβ that's a typo bestie, the real one isjabber:x:dataπ )
β° Time Functions β°
TimeQuery(to=>string, mode=>string, timeout=>int)β asks the jid you named for its localtime. Iftois blank, it just goes and queries the server instead. Returns a hash with all the juicy stuff filled in β but only ifmodeis set to"block":
$time{utc} - Time in UTC
$time{tz} - Timezone
$time{display} - Display string
TimeQuery()β yeah, you can call it with no args at all, same deal as above β¨
Peep the MODES section (back up above π) for how to actually usemodeandtimeout. Don't skip it, it's literally the whole vibe check for blocking vs non-blocking.
TimeSend(to=>string)β sends the current UTC time to the jid you specified. That's it. Slay, efficient, no notes. π
π₯οΈ Version Functions π₯οΈ
VersionQuery(to=>string, mode=>string, timeout=>int)β asks the jid you specified for its client version info. Iftois blank, it queries the server. Returns a hash with the good stuff set ifmodeis"block":
$version{name} - Name
$version{ver} - Version
$version{os} - Operating System/Platform
VersionQuery()β the no-argument version, same energy, same return π
Again: see MODES above formodeandtimeout. It's giving "read the docs", because you literally should πΈ
VersionSend(to=>string, name=>string, ver=>string, os=>string)β sends the version info you hand it over to the jid sitting into. Name, version, OS β the whole little identity card π
π AUTHOR π
Ryan Eatmon. That's the icon, that's the main character, that's who wrote this. π«Ά
π COPYRIGHT π
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Fr fr, go wild with it, just keep the same terms. π
okay that's a wrap on the whole page bestie!! π you made it to the very end, I'm so proud ππ this copy came from perl v5.42.2, dated 2026-02-15, and the page itself is Net::Ja...Protocol(3) β go build something iconic with it, mwah π
β¨π
π¦ where this page comes from
- alpine 3.24: perl-net-jabber-doc 2.0-r1 Β· LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms