|
|||||||||||||||||
Chat FunctionThe chat functionality controls the chat function (IM) of OKISoftphone on the server side. The SIP servlet that implements the functionality (OkiChatServlet) provides the following functions:
In the latest version (SIP Servlet Engine 3.0), only OKISoftphone is supported as a chat client. OkiChatServlet supports the following two types of groups:
OkiChatServlet can be used as a SIP application without being processed, in which case it supports only the AdHoc group. The Static group becomes available by creating an application that inherits this class. Manage member information of the Static group using database, etc. in this application. The specification overview of the chat function with OKISoftphone is as follows: For more information, see the OKI Softphone specification.
The chat function consists of the following classes: OkiChatServlet Classpackage com.oki.sip.equips.signal; public class OkiChatServlet extends BasicSipServlet { public String sendAdHocMessage(String sender, String receiver, String message, boolean echo); public String sendMessage(SipRequestParams params) throws Exception; protected void addAdHocMember(String groupID, SipURI uri); protected void removeAdHocMember(String groupID, SipURI uri); protected void addGroup(ChatGroup group); protected ChatGroup removeGroup(String groupID); protected void setChatMessageListener(ChatMessageListener listener); protected void removeChatMessageListener(); protected String sendAdHocMessage(SipURI sender, SipURI receiver, String message, boolean echo); protected void sendMessage(SipURI sender, String groupID, String message, boolean echo); protected void sendMessage(String sender, String groupID, String message, boolean echo); } The OkiChatServlet class is created as a servlet and defines two methods to request message sending as public methods. sendAdHocMessage is a method that sends a message to the user specified in the receiver argument. It creates a new AdHoc group at the same time. The first argument sender specifies string representation of the SIP URI of the sender, the second argument receiver specifies string representation of the SIP URI of the receiver, and the third argument message specifies the message body string. The fourth argument echo is a flag to determine whether a message is also sent to the sender itself. If true, the message is also sent to the sender. If false, the message is not sent to the sender. It returns groupID of the destination chat group as a return value. sendMessage is a method used to send a message from an HTTP servlet through SipRequestDispatcher.invoke. The following information can be set in SipRequestParams as application-specific arguments.
Like sendAdHocMessage, this method returns groupID of the destination chat group. Other methods are protected methods that are invoked from an application that inherits this class. addAdHocMember is a method that adds a member to the specified AdHoc group. The first argument groupID specifies a group ID of an existing AdHoc group. If the specified group does not exist, it creates a new AdHoc group with groupID. removeAdHocMember is a method that deletes a member from the specified AdHoc group. If the AdHoc group specified in the first argument groupID does not exist, IllegalArgumentException is thrown. If the AdHoc group exists but the target member does not exist, no exception is thrown. addGroup is a method to register a Static group. If you specify null or attempt to register a group already registered, IllegalArgumentException is thrown. removeGroup is a method to delete a Static group. It returns the deleted group. If you attempt to delete a non-existing group, it returns null. setChatMessageListener and removeChatMessageListener are methods that set or delete an event listener that receives all message logs via OkiChatServlet as an event. Only one event listener can be registered. If setChatMessageListener is invoked multiple times, only the last invocation is valid. The listener set with setChatMessageListener sends all messages including AdHoc groups as events. If you want to receive only messages within the specific group, use the event listening function of ChatGroup class. The second sendAdHocMessage method provides the same function as the sendAdHocMessage method except that sendAdHocMessage uses the SipURI class to specify the sender and receiver. sendMessage is a method to send a message to an existing group. The first argument sender specifies string representation of the SIP URI of the sender, the second argument groupID specifies ID information about the destination chat group. For an AdHoc group, the return value of the sendAdHocMessage method can be used as groupID. For a Static group, the return value of the getGroupID method of the ChatGroup interface can be used as groupID. The third argument message specifies the message body string. The fourth argument echo is a flag to determine whether a message is also sent to the sender itself. If true, the message is also sent to the sender. If false, the message is not sent to the sender. ChatMessageListener Interfacecom.oki.sip.equips.signal; public interface ChatMessageListener { void messageLog(String groupID, ChatMember sender, Date time, String message); } ChatMessageListener is an interface to receive an event of message logging. This interface only defines the messageLog method that delivers an event. The first argument of messageLog represents ID information about the destination chat group. The second represents the sender of the message. The third represents sending time of the message. The forth represents the message body. ChatGroup Interfacecom.oki.sip.equips.signal; public interface ChatGroup extends ChatMessageListener { String getGroupID(); Collection getAllMemberList(); } ChatGroup is an interface implemented by a class that represents a Static group. getGroupID is a method that returns ID information for identifying a group. It must return a unique group ID in the system. The AdHoc group uses a name beginning with "adhoc-" as a group ID. Do not use an overlapping group ID. getAllMemberList is a method that returns a list of all the members who belong to the Static group. This method must return Cllection that contains the ChatMember object. This method is called each time a message is delivered. Therefore, change of a member that belongs to the Static group does not need to be sent to OkiChatServlet. The message is sent to members contained in the return value of this method . ChatMember Classcom.oki.sip.equips.signal; public class ChatMember { public ChatMember(SipURI uri, Address contact, String displayName); Address getContact(); String getDisplayName(); SipURI getURI(); } ChatMember is a class that stores information about members joining in a chat group. It is used as the return value of getAllMemberList of the ChatGroup interface. Last Modified:Thu Mar 25 12:29:15 AM JST 2004 |
|||||||||||||||||
|