JabAppendix B

From WikiContent

(Difference between revisions)
Jump to: navigation, search
(The IQRPC Class)
Current revision (14:24, 18 September 2009) (edit) (undo)
(content navi added)
 
(5 intermediate revisions not shown.)
Line 1: Line 1:
 +
{{Content Programming Jabber}}
=The IQRPC Classes for JabberRPCResponder=
=The IQRPC Classes for JabberRPCResponder=
<br>This appendix contains the two
<br>This appendix contains the two
Line 12: Line 13:
== The IQRPC Class ==
== The IQRPC Class ==
<br>
<br>
-
<code>// IQRPC.java
+
<code>
 +
<br> // IQRPC.java
-
import org.jabber.jabberbeans.*; import
+
import org.jabber.jabberbeans.*; import
-
org.jabber.jabberbeans.Extension.*;
+
org.jabber.jabberbeans.Extension.*;
-
public class IQRPC extends XMLData implements QueryExtension { private
+
public class IQRPC extends XMLData implements QueryExtension { private
-
String payload;
+
String payload;
public IQRPC(IQRPCBuilder builder) { payload=builder.getPayload();
public IQRPC(IQRPCBuilder builder) { payload=builder.getPayload();
Line 30: Line 32:
retval.append(payload); retval.append("&lt;/query&gt;");
retval.append(payload); retval.append("&lt;/query&gt;");
}
}
-
}
+
}
-
}</code>
+
}
 +
</code>
 +
<br>
== The IQRPCBuilder Class ==
== The IQRPCBuilder Class ==
-
<code>// IQRPCBuilder.java
+
<code>
 +
<br>// IQRPCBuilder.java
-
import org.jabber.jabberbeans.*; import
+
import org.jabber.jabberbeans.*; import
-
org.jabber.jabberbeans.Extension.*;
+
org.jabber.jabberbeans.Extension.*;
-
public class IQRPCBuilder implements ExtensionBuilder { private String
+
public class IQRPCBuilder implements ExtensionBuilder { private String
-
payload;
+
payload;
public IQRPCBuilder() { reset();
public IQRPCBuilder() { reset();
Line 57: Line 62:
public Extension build() { return new IQRPC(this);
public Extension build() { return new IQRPC(this);
}
}
-
}
+
}
</code>
</code>
-
</content></appendix>
 

Current revision

Programming Jabber
Preface
1 - Getting started with Jabber
2 - Inside Jabber
3 - Installing the Jabber server
4 - Server Architecture and Configuration
5 - Jabber Technology Basics
6 - Jabber Namespaces
7 - User Registration and Authorization
8 - Using Messages and Presence
9 - Groupchat, : Components, and Event Models
10 - Pointers for Further Development
Appendix A
Appendix B
Colophon

The IQRPC Classes for JabberRPCResponder


This appendix contains the two IQRPC classes, IQRPC and IQRPCBuilder. They are required for the Java JabberRPCResponder script in Section 10.2.

They're essentially modified copies of two existing and equivalent classes for the jabber:iq:time namespace, IQTime and IQTimeBuilder.



The IQRPC Class



// IQRPC.java

import org.jabber.jabberbeans.*; import
org.jabber.jabberbeans.Extension.*;
public class IQRPC extends XMLData implements QueryExtension { private
String payload;
   public IQRPC(IQRPCBuilder builder) { payload=builder.getPayload();
   }
   public String getPayload() { return payload;
   }
   public void appendItem(StringBuffer retval) {
   retval.append("<query xmlns=\"jabber:iq:rpc\">");
   retval.append(payload); retval.append("</query>");
   }
}
}


The IQRPCBuilder Class


// IQRPCBuilder.java

import org.jabber.jabberbeans.*; import
org.jabber.jabberbeans.Extension.*;
public class IQRPCBuilder implements ExtensionBuilder { private String
payload;
   public IQRPCBuilder() { reset();
   }
   public void reset() { payload=null;
   }
   public String getPayload() { return payload;
   }
   public void setPayload(String value) { payload=value;
   }
   public Extension build() { return new IQRPC(this);
   }
}

Personal tools