]> git.cworth.org Git - loa-java/commitdiff
Initial import (simple test of smack basics) master
authorCarl Worth <cworth@cworth.org>
Thu, 20 Mar 2008 00:05:34 +0000 (17:05 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 20 Mar 2008 00:05:34 +0000 (17:05 -0700)
Loa.java [new file with mode: 0644]

diff --git a/Loa.java b/Loa.java
new file mode 100644 (file)
index 0000000..ed29824
--- /dev/null
+++ b/Loa.java
@@ -0,0 +1,63 @@
+/* Compile:
+ *
+ *     javac -classpath ./smack_3_0_4/smack.jar Loa.java
+ *
+ * Run:
+ *
+ *     java -classpath .:./smack_3_0_4/smack.jar:./smack_3_0_4/smackx.jar Loa
+ */
+
+import org.jivesoftware.smack.*;
+import org.jivesoftware.smack.packet.*;
+
+/**
+ * Loa: A Java implementation of Lines of Action (eventually, anyway)
+ * 
+ * @author Carl Worth
+ */
+public class Loa
+{
+    public static void main(String[] args) {
+       ConnectionConfiguration config;
+       XMPPConnection conn;
+       ChatManager chat_manager;
+       Chat chat;
+
+       config = new ConnectionConfiguration ("jabber.friendlygames.org", 5222);
+       conn = new XMPPConnection(config);
+
+       try {
+           conn.connect();
+       } catch (XMPPException e) {
+           System.out.println ("connect() failed");
+       }
+
+       try {
+           conn.login ("test", "19zulu.");
+       } catch (XMPPException e) {
+           System.out.println ("login() failed");
+       }
+
+       try {
+           chat_manager = conn.getChatManager();
+           chat = chat_manager.createChat("cworth@jabber.friendlygames.org",
+                  new MessageListener() {
+                      public void processMessage (Chat chat, Message message) {
+                          System.out.println ("Received message: " + message);
+                      }
+                  });
+
+           chat.sendMessage ("Hello, from smack.");
+       } catch (XMPPException e) {
+           System.out.println ("sendMessage() failed");
+       }
+
+       while (true) {
+           Long one_second = 1000L;
+           try {
+               Thread.sleep (one_second);
+           } catch (InterruptedException e) {
+           }
+       }
+    }
+}