1 package org.opensrf.test;
3 import org.opensrf.net.xmpp.XMPPReader;
4 import org.opensrf.net.xmpp.XMPPMessage;
5 import org.opensrf.net.xmpp.XMPPSession;
7 public class TestXMPP {
10 * Connects to the jabber server and waits for inbound messages.
11 * If a recipient is provided, a small message is sent to the recipient.
13 public static void main(String args[]) throws Exception {
24 port = Integer.parseInt(args[1]);
29 } catch(ArrayIndexOutOfBoundsException e) {
30 System.err.println("usage: org.opensrf.test.TestXMPP <host> <port> <username> <password> <resource> [<recipient>]");
34 XMPPSession session = new XMPPSession(host, port);
35 session.connect(username, password, resource);
39 if( args.length == 6 ) {
41 /** they specified a recipient */
44 msg = new XMPPMessage();
46 msg.setThread("test-thread");
47 msg.setBody("Hello, from java-xmpp");
48 System.out.println("Sending message to " + recipient);
53 System.out.println("waiting for message...");
54 msg = session.recv(-1); /* wait forever for a message to arrive */
55 System.out.println("got message: " + msg.toXML());