From e1b93839d7796ecc6acdfdad33718c5b95c2ddd0 Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Sun, 4 Feb 2007 22:53:16 +0000 Subject: [PATCH] Doc updates. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@6950 b35dd754-fafc-0310-a699-88a17e54d16e --- documentation/gettingstarted.html | 23 +++++----- documentation/index.html | 6 +-- documentation/messaging.html | 75 +++++++++---------------------- 3 files changed, 33 insertions(+), 71 deletions(-) diff --git a/documentation/gettingstarted.html b/documentation/gettingstarted.html index 127867885..b2dfd1894 100644 --- a/documentation/gettingstarted.html +++ b/documentation/gettingstarted.html @@ -23,34 +23,33 @@ important classes and concepts. Requirements

-The only requirement for Smack is JDK 1.2 or later -1. -An XML parser is embedded in the smack.jar file and no other third party -libraries are required.

+The only requirement for Smack is JDK 1.5 or later. An XML parser is embedded in the +smack.jar file and no other third party libraries are required.

-1 JDK 1.2 and 1.3 users that wish to use SSL connections must have the -JSSE library in their classpath.

Establishing a Connection

The XMPPConnection class is used to create a connection to an -XMPP server. To create an SSL connection, use the SSLXMPPConnection class. -Below are code examples for making a connection:

+XMPP server. Below are code examples for making a connection:

 // Create a connection to the jabber.org server.
 XMPPConnection conn1 = new XMPPConnection("jabber.org");
+conn1.connect();
 
 // Create a connection to the jabber.org server on a specific port.
-XMPPConnection conn2 = new XMPPConnection("jabber.org", 5222);
-
-// Create an SSL connection to jabber.org.
-XMPPConnection connection = new SSLXMPPConnection("jabber.org"); 
+ConnectionConfiguration config = new ConnectionConfiguration("jabber.org", 5222);
+XMPPConnection conn2 = new XMPPConnection(config);
+conn2.connect();
 
+

Note that maximum security will be used when connecting to the server by default (and when possible), + including use of TLS encryption. The ConnectionConfiguration class provides advanced control + over the connection created, such as the ability to disable or require encryption.

+

Once you've created a connection, you should login using a username and password with the XMPPConnection.login(String username, String password) method. Once you've logged in, you can being chatting with other users by creating diff --git a/documentation/index.html b/documentation/index.html index b7e6afb7a..2bfcdab7b 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -6,11 +6,7 @@ -
-Smack - Smack Documentation -

Contents: @@ -31,7 +27,7 @@

diff --git a/documentation/messaging.html b/documentation/messaging.html index 46dd5a8a1..d9fc8c708 100644 --- a/documentation/messaging.html +++ b/documentation/messaging.html @@ -7,7 +7,7 @@
-Messaging using Chat and GroupChat +Messaging using Chats

-Sending messages back and forth is at the core of instant messaging. Two classes -aid in sending and receiving messages: -

- -Both the Chat and GroupChat classes use the org.jivesoftware.smack.packet.Message packet -class to send messages. In certain circumstances, you may wish to bypass the higher-level -Chat and GroupChat classes to send and listen for messages directly. +Sending messages back and forth is at the core of instant messaging. Although individual messages +can be sent and received as packets, it's generally easier to treat the string of messages +as a chat using the org.jivesoftware.smack.Chat class.

@@ -37,8 +30,13 @@ them a text message:

 // Assume we've created an XMPPConnection name "connection".
-Chat newChat = connection.createChat("jsmith@jivesoftware.com");
-newChat.sendMessage("Howdy!");
+Chat newChat = connection.createChat("jsmith@jivesoftware.com", new MessageListener() {
+
+    public void processMessage(Chat chat, Message message) {
+        System.out.println("Received message: " + message);
+    }
+});
+chat.sendMessage("Howdy!");
 

The Chat.sendMessage(String) method is a convenience method that creates a Message @@ -48,60 +46,29 @@ that you wish to set additional values on a Message before sending it, use the following code snippet:

-// Assume we've created an XMPPConnection name "connection".
-Chat newChat = connection.createChat("jsmith@jivesoftware.com");
 Message newMessage = newChat.createMessage();
 newMessage.setBody("Howdy!");
 message.setProperty("favoriteColor", "red");
 newChat.sendMessage(newMessage);
 

-The Chat object allows you to easily listen for replies from the other chat participant. -The following code snippet is a parrot-bot -- it echoes back everything the other user types.

+You'll also notice in the example above that we specified a MessageListener when creating a chat. +The listener is notified any time a new message arrives from the other user in the chat. +The following code snippet uses the listener as a parrot-bot -- it echoes back everything the other user types.

-// Assume we've created an XMPPConnection name "connection".
-Chat newChat = connection.createChat("jsmith@jivesoftware.com");
-newMessage.setBody("Hi, I'm an annoying parrot-bot! Type something back to me.");
-while (true) {
-    // Wait for the next message the user types to us.
-    Message message = newChat.nextMessage();
-    // Send back the same text the other user sent us.
-    newChat.sendMessage(message.getBody());
-}
+    // Assume a MessageListener we've setup with a chat.
+
+    public void processMessage(Chat chat, Message message) {
+        // Send back the same text the other user sent us.
+        chat.sendMessage(message.getBody());
+    }
 

-The code above uses the Chat.nextMessage() method to get the next message, which -will wait indefinitely until another message comes in. There are other methods to wait -a specific amount of time for a new message, or you can add a listener that will be notified -every time a new message arrives. - -

-GroupChat -

- -A group chat connects to a chat room on a server and allows you to send and receive messages -from a group of people. Before you can send or receive messages, you must join the room using -a nickname. The following code snippet connects to a chat room and sends a -message.

- -

-// Assume we've created an XMPPConnection name "connection".
-GroupChat newGroupChat = connection.createGroupChat("test@jivesoftware.com");
-// Join the group chat using the nickname "jsmith".
-newGroupChat.join("jsmith");
-// Send a message to all the other people in the chat room.
-newGroupChat.sendMessage("Howdy!");
-

- -In general, sending and receiving messages in a group chat works very similarly to -the Chat class. Method are also provided to get the list of the other -users in the room.

-