com.echomine.jabber
Class JabberChatService

java.lang.Object
  extended by com.echomine.jabber.JabberChatService
All Implemented Interfaces:
PresenceCode

public class JabberChatService
extends java.lang.Object
implements PresenceCode

This service deals with all aspects of chatting (private one-on-one, group chats, headlines, etc). You can use this service to send private messages, to send group chat messages, or to reply to messages. A special note: most of the old group chatting functionality are replaced with the newer conference-style chatting. This service supports only the old style for backwards compatibility. In fact, currently only the commercial Jabber server supports the new conferencing protocol (and it uses a special draft conference namespace). Another service will be created to handle conferencing-style chat rooms.

There are currently several different types of chatting available. The "chat" type is your regular one-on-one chatting. The "groupchat" is the chatroom-style chatting. The "headline" is more of a notification. The "normal" is used when no type is specified. Usually you would open a new window for each specific JID you're chatting with. You should just treat "normal" types the same as "chat" types by default.

Note that the group chat capability is the predecessor of the new Conferencing feature, and are technically NOT the same thing.

Private Chatting Notes

Private chatting support both plain text and XHTML text. It is up to you to parse the HTML text if you support it. It is also up to you to create the XHTML message. The Chat Service currently gives you rudimentary methods to send messages with XHTML support. If you require any advanced function, you should instantiate your own JabberChatMessage, set the proper fields, and send the message yourself.


Field Summary
 
Fields inherited from interface com.echomine.jabber.PresenceCode
SHOW_AWAY, SHOW_CHAT, SHOW_DO_NOT_DISTURB, SHOW_EXTENDED_AWAY, SHOW_ONLINE, TYPE_AVAILABLE, TYPE_INVISIBLE, TYPE_PROBE, TYPE_SUBSCRIBE, TYPE_SUBSCRIBED, TYPE_UNAVAILABLE, TYPE_UNSUBSCRIBE, TYPE_UNSUBSCRIBED
 
Constructor Summary
JabberChatService(JabberSession session)
           
 
Method Summary
 void joinChatRoom(JID roomJID, java.lang.String nick, boolean wait)
          joins a chat room with a specified arbitrary nickname.
 void leaveChatRoom(JID roomJID, boolean wait)
          leaves a chat room that you are currently in.
 void replyToPrivateMessage(JID toJID, java.lang.String threadID, java.lang.String body, boolean wait)
          replies to a message.
 void sendChatMessage(JID roomJID, java.lang.String body, boolean wait)
          a simple method to send a text message to the chat room.
 void sendPrivateMessage(JID toJID, java.lang.String body, boolean wait)
          sends a private message to a specific JID that's plain text.
 void setChatAvailable(JID roomJID, java.lang.String showState, java.lang.String status, boolean wait)
          sets status to available with optional show state and status line for a specific chat room.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JabberChatService

public JabberChatService(JabberSession session)
Method Detail

sendPrivateMessage

public void sendPrivateMessage(JID toJID,
                               java.lang.String body,
                               boolean wait)
                        throws SendMessageFailedException
sends a private message to a specific JID that's plain text. If you want to use HTML, you will need to instantiate your own Chat Message and set the HTML body yourself. Subject is not normally needed since most other IMs don't use subjects.

Parameters:
toJID - the JID to send the message to
body - the plain text body of the message
wait - true if the caller wants to wait until there is a reply to the message
Throws:
SendMessageFailedException

replyToPrivateMessage

public void replyToPrivateMessage(JID toJID,
                                  java.lang.String threadID,
                                  java.lang.String body,
                                  boolean wait)
                           throws SendMessageFailedException
replies to a message. It is fairly simple in that it simply takes the From and ThreadID fields from the original message and uses them to set the To and ThreadID of the reply message

Parameters:
toJID - the JID to send the message back to
threadID - the thread id of the originating message
body - the body text
wait - true if the caller wants to wait until there is a reply to the message
Throws:
SendMessageFailedException

joinChatRoom

public void joinChatRoom(JID roomJID,
                         java.lang.String nick,
                         boolean wait)
                  throws SendMessageFailedException
joins a chat room with a specified arbitrary nickname. Currently, joining chat rooms uses the old style of joining, not the new conferencing style as it's not fully supported by Jabber Servers yet. Any result from joining the room will be fired off as message events (which you should listen to).

Parameters:
roomJID - the jid of the room, in the form of room@server
nick - the nickname to be used in the room
wait - true if the caller wants to wait until there is a reply to the message
Throws:
SendMessageFailedException

leaveChatRoom

public void leaveChatRoom(JID roomJID,
                          boolean wait)
                   throws SendMessageFailedException
leaves a chat room that you are currently in. When you leave, you will received an unavailable presence that is sent from the room JID.

Parameters:
roomJID - the JID of the room to leave
wait - true if the caller wants to wait until there is a reply to the message
Throws:
SendMessageFailedException

sendChatMessage

public void sendChatMessage(JID roomJID,
                            java.lang.String body,
                            boolean wait)
                     throws SendMessageFailedException
a simple method to send a text message to the chat room. If you want to send XHTML text, you will have to instantiate your own Chat Message.

Parameters:
roomJID - the JID of the chat room
body - the text to send to the chat room
wait - true if the caller wants to wait until there is a reply to the message
Throws:
SendMessageFailedException

setChatAvailable

public void setChatAvailable(JID roomJID,
                             java.lang.String showState,
                             java.lang.String status,
                             boolean wait)
                      throws SendMessageFailedException
sets status to available with optional show state and status line for a specific chat room. Use this to set your status as either away, extended away, etc. To set back to available, simply set show state and status to null and you will be set back to available. The priority is set to default 0.

Parameters:
roomJID - the JID of the room to send the availability to
showState - optional parameter to set the show state (chat, away, extended away, etc), null if not setting a state
status - the status to set, or null if not setting a status text
wait - true if the caller wants to wait until there is a reply to the message
Throws:
SendMessageFailedException


Copyright © 2001-2005 Echomine. All Rights Reserved.