Monday, November 08, 2010 at 12:06 AM.
system.verbs.builtins.tcp.im.builtinDrivers.jabber.code.examples.rpc.xmlrpcResponse
on xmlrpcResponse ( connection, mesAdr, iq, query) {
<<Changes
<<5/14/02; 1:51:34 PM by JB
<<Changelog created.
<<This handles receiving a methodResponse, converting the response back into Frontier types, and turning control over to either the jabber.rpc call (synchronous), or the user-registered callback (asynchronous).
local ( methodResponse, id, from, type, params, param, value, flGotRpcError = false, fault, struct, memberlist, faultCode, faultString );
id = xml.getAttributeValue(iq, "id");
id = tcp.im.builtinDrivers.jabber.code.idTables.getAdr(id);
if id == "" { // no idtable at all, we forgot this call or it's spoofed, just ignore it
return};
methodResponse = xml.getAddress(query, "methodResponse" );
bundle { // extract response, store in idTable appropriately
try {
params = xml.getAddress(methodResponse, "params");
param = xml.getAddress(params, "param");
id^.jabberXMLRPCResult = xml.getValue(param, "value");
if typeOf ( value ) == tableType {
local ( newValue );
xml.coercions.structToFrontierValue(@id^.jabberXMLRPCResult[1], @newValue);
table.assign(@id^.jabberXMLRPCResult, newValue)}}
else { // we have an error
flGotRpcError = true;
fault = xml.getAddress(methodResponse, "fault");
value = xml.getAddress(fault, "value");
struct = xml.getAddress(value, "struct");
memberlist = xml.getAddressList(struct, "member");
for member in memberlist {
local ( name = xml.getValue(member, "name"), value = xml.getValue(member, "value") );
case name {
"faultCode" {
id^.JabberXMLRPCFaultCode = value};
"faultString" {
id^.JabberXMLRPCFaultString = value}}}}};
if id^.jabberXMLRPCflAsync { // this was an asynchronous call, so call the given script and exit
if not flGotRpcError {
if defined ( id^.jabberXMLRPCCallback^ ) {
try {
id^.jabberXMLRPCCallback^ ( id^.jabberXMLRPCResult, id, id^.jabberXMLRPCExtraInfo)}};
delete (id); // we know we don't need to run the cleanup now
return}
else {
if defined ( id^.jabberXMLRPCErrorCallback^ ) {
try {
id^.jabberXMLRPCErrorCallback^ ( id, id^.JabberXMLRPCFaultCode, id^.JabberXMLRPCFaultString )}};
delete (id); // we know we don't need to run the cleanup now
return}};
return}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.