From: Carl Worth Date: Thu, 20 Mar 2008 00:05:34 +0000 (-0700) Subject: Initial import (simple test of smack basics) X-Git-Url: https://git.cworth.org/git?p=loa-java;a=commitdiff_plain;h=HEAD Initial import (simple test of smack basics) --- 67f3a526d5b5e4b448331ac4282116780ad7bdc6 diff --git a/Loa.java b/Loa.java new file mode 100644 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) { + } + } + } +}