Class CMSessionEvent


public class CMSessionEvent extends CMEvent
This class represents CM events that are used for session related tasks.
See Also:
  • Field Details

    • LOGIN

      public static final int LOGIN
      The event ID for login request from a client to the default server.

      event direction: client -> default server

      The LOGIN event is sent when the client calls CMClientStub.loginCM(String, String) or CMClientStub.syncLoginCM(String, String).
      The following fields are used for this event:

      See Also:
    • LOGOUT

      public static final int LOGOUT
      The event ID for logout request from a client to the default server.

      event direction: client -> default server

      The LOGOUT event is sent when the client calls CMClientStub.logoutCM().
      The following field is used for this event:

      See Also:
    • LOGIN_ACK

      public static final int LOGIN_ACK
      The event ID for response to the login request from the default server to the client.

      event direction: default server -> client

      The default server sends the LOGIN_ACK event to the client as the response to the LOGIN event.
      The following fields are used for this event:

      • response code: isValidUser()
        1: valid user, 0: invalid user
      • communication architecture: getCommArch()
        CM_CS: This CM network is client-server model
        CM_PS: This CM network is peer-server model
      • file-transfer scheme: isFileTransferScheme()
        1: to use a separate channel and thread to transfer a file
        0: to use the default socket channel to transfer a file
      • login scheme: isLoginScheme()
        1: The default server authenticates the requesting user
        0: The default server does not authenticates the requesting user
      • session scheme: isSessionScheme()
        1: The login user should select and join a session.
        0: The login user automatically joins a default session.
      • download scheme of attached files in SNS content: getAttachDownloadScheme()
        0: full mode, 1: partial mode, 2: prefetch mode, 3: none
      • server UDP port: getUDPPort()
      See Also:
    • REQUEST_SESSION_INFO

      public static final int REQUEST_SESSION_INFO
      The event ID for requesting available session information from the default server.

      event direction: client -> default server

      The REQUEST_SESSION_INFO event is sent when the client calls CMClientStub.requestSessionInfo().
      The following field is used for this event:

      See Also:
    • RESPONSE_SESSION_INFO

      public static final int RESPONSE_SESSION_INFO
      The event ID for the response to the request of available session information.

      event direction: default server -> client

      The RESPONSE_SESSION_INFO event is the reply of the REQUEST_SESSION_INFO event.
      The following fields are used for this event:

      See Also:
    • JOIN_SESSION

      public static final int JOIN_SESSION
      The event ID for the request of joining a session.

      event direction: client -> default server

      The JOIN_SESSION event is sent when the client calls CMClientStub.joinSession(String) and CMClientStub.syncJoinSession(String).
      The following fields are used for this event:

      See Also:
    • JOIN_SESSION_ACK

      public static final int JOIN_SESSION_ACK
      The event ID for the response to the request of joining a session.

      event direction: default session -> client

      The JOIN_SESSION_ACK event is the reply of the JOIN_SESSION event.
      The following fields are used for this event:

      See Also:
    • LEAVE_SESSION

      public static final int LEAVE_SESSION
      The event ID for the request of leaving the current session.

      event direction: client -> default server

      The LEAVE_SESSION event is sent when the client calls CMClientStub.leaveSession().
      The following fields are used for this event:

      See Also:
    • LEAVE_SESSION_ACK

      public static final int LEAVE_SESSION_ACK
      See Also:
    • SESSION_TALK

      public static final int SESSION_TALK
      The event ID for a chat message of a client which has logged in to the server but does not join a session.

      event direction: client -> server -> client

      The SESSION_TALK event is sent when the client calls CMClientStub.chat(String, String).
      The following fields are used for this event:

      See Also:
    • SESSION_ADD_USER

      public static final int SESSION_ADD_USER
      The event ID for the notification of a new logged-in user.

      event direction: default server -> client

      The default server sends the SESSION_ADD_USER event to the existing users to notify them of a new logged-in user.
      The following fields are used for this event:

      See Also:
    • SESSION_REMOVE_USER

      public static final int SESSION_REMOVE_USER
      The event ID for the notification of the user logout.

      event direction: default server -> client

      The default server sends the SESSION_REMOVE_USER event to the existing users to notify that a user has logged out from the default server.
      The following fields are used for this event:

      See Also:
    • CHANGE_SESSION

      public static final int CHANGE_SESSION
      The event ID for the notification of a user joining(changing) a session.

      event direction: default server -> client

      The default server sends the CHANGE_SESSION event to the existing users to notify that a user has joined a session.
      The following fields are used for this event:

      See Also:
    • ADD_NONBLOCK_SOCKET_CHANNEL

      public static final int ADD_NONBLOCK_SOCKET_CHANNEL
      The event ID for the request to add a non-blocking socket channel information.

      event direction: client -> server

      The ADD_NONBLOCK_SOCKET_CHANNEL is sent when the client calls CMClientStub.addNonBlockSocketChannel(int, String) or CMClientStub.syncAddNonBlockSocketChannel(int, String).
      The following fields are used for this event:

      • channel name: getChannelName()
        The name of a server to which the client establishes a connection.
      • channel index: getChannelNum()
        the index(>0) for the socket channel.
      See Also:
    • ADD_NONBLOCK_SOCKET_CHANNEL_ACK

      public static final int ADD_NONBLOCK_SOCKET_CHANNEL_ACK
      The event ID for the response to the request of adding a non-blocking socket channel information.

      event direction: server -> client

      The ADD_NONBLOCK_SOCKET_CHANNEL_ACK event is the reply of the ADD_NONBLOCK_SOCKET_CHANNEL event.
      The following fields are used for this event:

      • channel name: getChannelName()
        The name of a server to which the client establishes a connection.
      • channel index: getChannelNum()
        the index(>0) for the socket channel.
      • return code: getReturnCode()
        0: channel addition at the server has completed.
        other value: channel addition at the server has failed.
      See Also:
    • ADD_BLOCK_SOCKET_CHANNEL

      public static final int ADD_BLOCK_SOCKET_CHANNEL
      The event ID for the request to add a blocking socket channel information.

      event direction: client -> server
      event direction: client -> client in the p2p file transfer

      The ADD_BLOCK_SOCKET_CHANNEL is sent when the client calls CMClientStub.addBlockSocketChannel(int, String) or CMClientStub.syncAddBlockSocketChannel(int, String).
      A file sender client also can send this event to a file receiver client to make a dedicated channel if the FILE_TRANSFER_SCHEME field is set to 1 in the server CM configuration file (cm-server.conf).
      The following fields are used for this event:

      • channel name: getChannelName()
        The name of a server to which the client establishes a connection.
      • channel index: getChannelNum()
        the index(>=0) for the socket channel.
      See Also:
    • ADD_BLOCK_SOCKET_CHANNEL_ACK

      public static final int ADD_BLOCK_SOCKET_CHANNEL_ACK
      The event ID for the response to the request of adding a blocking socket channel information.

      event direction: server -> client

      The ADD_BLOCK_SOCKET_CHANNEL_ACK event is the reply of the ADD_BLOCK_SOCKET_CHANNEL event.
      The following fields are used for this event:

      • channel name: getChannelName()
        The name of a server to which the client establishes a connection.
      • channel index: getChannelNum()
        the index(>=0) for the socket channel.
      • return code: getReturnCode()
        0: channel addition at the server has completed.
        other value: channel addition at the server has failed.
      See Also:
    • REMOVE_BLOCK_SOCKET_CHANNEL

      public static final int REMOVE_BLOCK_SOCKET_CHANNEL
      The event ID for the request to remove a blocking socket channel information.

      event direction: client -> server
      event direction: client -> client in the p2p file transfer

      The REMOVE_BLOCK_SOCKET_CHANNEL is sent when the client calls CMClientStub.removeBlockSocketChannel(int, String), or CMClientStub.syncRemoveBlockSocketChannel(int, String).
      A file sender or receiver client also can send this event to finish or cancel the file transfer with a dedicated channel if the FILE_TRANSFER_SCHEME field is set to 1 in the server CM configuration file (cm-server.conf).
      The following fields are used for this event:

      • channel name: getChannelName()
        The name of a server to which the client establishes a connection.
      • channel index: getChannelNum()
        the index(>=0) for the socket channel.
      See Also:
    • REMOVE_BLOCK_SOCKET_CHANNEL_ACK

      public static final int REMOVE_BLOCK_SOCKET_CHANNEL_ACK
      The event ID for the response to the request of removing a blocking socket channel information.

      event direction: server -> client

      The REMOVE_BLOCK_SOCKET_CHANNEL_ACK event is the reply of the REMOVE_BLOCK_SOCKET_CHANNEL event.
      The following fields are used for this event:

      • channel name: getChannelName()
        The name of a server to which the client establishes a connection.
      • channel index: getChannelNum()
        the index(>=0) for the socket channel.
      • return code: getReturnCode()
        0: the channel has been removed successfully.
        other value: channel removal at the server has failed.
      See Also:
    • REGISTER_USER

      public static final int REGISTER_USER
      The event ID for the request of registering a new user from the default server.

      event direction: client -> default server

      The REGISTER_USER event is sent when the client calls CMClientStub.registerUser(String, String).
      The following fields are used for this event:

      See Also:
    • REGISTER_USER_ACK

      public static final int REGISTER_USER_ACK
      The event ID for the response to the request of registering a new user.

      event direction: default server -> client

      The REGISTER_USER_ACK event is the reply of the REGISTER_USER event.
      The following fields are used for this event:

      See Also:
    • DEREGISTER_USER

      public static final int DEREGISTER_USER
      The event ID for the request of deregistering a user from the default server.

      event direction: client -> default server

      The DEREGISTER_USER event is sent when the client calls CMClientStub.deregisterUser(String, String).
      The following fields are used for this event:

      See Also:
    • DEREGISTER_USER_ACK

      public static final int DEREGISTER_USER_ACK
      The event ID for the response to the request of deregistering a user from the default server.

      event direction: default server -> client

      The DEREGISTER_USER_ACK event is the reply of the DEREGISTER_USER event.
      The following fields are used for this event:

      See Also:
    • FIND_REGISTERED_USER

      public static final int FIND_REGISTERED_USER
      The event ID for the request of searching for a registered user from the default server.

      event direction: client -> default server

      The FIND_REGISTERED_USER event is sent when the client calls CMClientStub.findRegisteredUser(String).
      The following field is used for this event:

      See Also:
    • FIND_REGISTERED_USER_ACK

      public static final int FIND_REGISTERED_USER_ACK
      The event ID for the response to the request of searching for a registered user.

      event direction: default server -> client

      The FIND_REGISTERED_USER_ACK event is the reply of the FIND_REGISTERED_USER event.
      The following fields are used for this event:

      See Also:
    • UNEXPECTED_SERVER_DISCONNECTION

      public static final int UNEXPECTED_SERVER_DISCONNECTION
      The event ID for notifying the client of unexpected disconnection from a server.

      event direction: client CM -> client application (local event)

      The client CM delivers the UNEXPECTED_SERVER_DISCONNECTION event to its application when it detects the disconnection from a server CM.
      The following fields are used for this event:

      See Also:
    • INTENTIONALLY_DISCONNECT

      public static final int INTENTIONALLY_DISCONNECT
      The event ID for notifying the application of intentional disconnection from a remote node by CM.

      event direction: CM -> application (local event)

      CM delivers the INTENTIONALLY_DISCONNECT event to its application when it disconnects a problematic non-blocking socket channel. A non-blocking socket channel is regarded as problematic if
      (1) CM receives a malformed CM event.
      (2) the server keep-alive task enables and it detects the expiration of the keep-alive time of the channel. The server CM enables the keep-alive task if the KEEP_ALIVE_TIME field of the configuration file is set to a value greater than 0.

      The following fields are used for this event:

      • channel name: getChannelName()
        name of remote node with the problematic socket channel disconnected by the local CM.
      • channel index: getChannelNum()
        index of the problematic non-blocking socket channel disconnected by the local CM.
      See Also:
  • Constructor Details

    • CMSessionEvent

      public CMSessionEvent()
    • CMSessionEvent

      public CMSessionEvent(ByteBuffer msg)
  • Method Details

    • setHostAddress

      public void setHostAddress(String host)
    • getHostAddress

      public String getHostAddress()
      Returns the host IP address.
      Returns:
      the IP address.
    • setUDPPort

      public void setUDPPort(int port)
    • getUDPPort

      public int getUDPPort()
      Returns UDP port number.
      Returns:
      UDP port number.
    • setPassword

      public void setPassword(String passwd)
    • getPassword

      public String getPassword()
      Returns the password.
      Returns:
      password.
    • setUserName

      public void setUserName(String uname)
    • getUserName

      public String getUserName()
      Returns the user name.
      Returns:
      user name.
    • setValidUser

      public void setValidUser(int bValid)
    • isValidUser

      public int isValidUser()
      Returns if the user authentication has succeeded or not.
      Returns:
      1 if the user is authenticated; 0 otherwise.
    • setSessionName

      public void setSessionName(String sname)
    • getSessionName

      public String getSessionName()
      Returns the session name.
      Returns:
      session name.
    • setCommArch

      public void setCommArch(String commArch)
    • getCommArch

      public String getCommArch()
      Returns the communication architecture of the server.
      Returns:
      communication architecture.
      "CM_CS" or "CM_PS".
    • setFileTransferScheme

      public void setFileTransferScheme(int bFileTransferScheme)
    • isFileTransferScheme

      public int isFileTransferScheme()
      Returns if the new file-transfer scheme is on or off.
      Returns:
      1 if the new file-transfer scheme is on; 0 otherwise.
    • setLoginScheme

      public void setLoginScheme(int bLoginScheme)
    • isLoginScheme

      public int isLoginScheme()
      Returns if the server authenticates a user or not.
      Returns:
      1 if the user authentication is used; 0 otherwise.
    • setSessionScheme

      public void setSessionScheme(int bSessionScheme)
    • isSessionScheme

      public int isSessionScheme()
      Returns if the server uses multiple sessions or not.
      Returns:
      1 if multiple sessions are used; 0 otherwise.
    • setAttachDownloadScheme

      public void setAttachDownloadScheme(int nScheme)
    • getAttachDownloadScheme

      public int getAttachDownloadScheme()
      Returns the current download mode of an image file attached to SNS content.
      Returns:
      the download mode.
      0: full (original image)
      1: partial (thumbnail image)
      2: prefetch (prefetch original image)
      3: none (text information)
    • setReturnCode

      public void setReturnCode(int code)
    • getReturnCode

      public int getReturnCode()
      Returns the return code.
      Returns:
      1 for successful return code; 0 otherwise.
    • setTalk

      public void setTalk(String talk)
    • getTalk

      public String getTalk()
      Returns the chatting message.
      Returns:
      chatting message.
    • setCurrentGroupName

      public void setCurrentGroupName(String gname)
    • getCurrentGroupName

      public String getCurrentGroupName()
      Returns the current group name.
      Returns:
      the current group name.
    • setCurrentAddress

      public void setCurrentAddress(String addr)
    • getCurrentAddress

      public String getCurrentAddress()
      Returns the current address.
      Returns:
      the current address.
    • setCurrentPort

      public void setCurrentPort(int port)
    • getCurrentPort

      public int getCurrentPort()
      Returns the current port number.
      Returns:
      the current port number.
    • setChannelName

      public void setChannelName(String name)
    • getChannelName

      public String getChannelName()
      Returns the channel name.
      Returns:
      the channel name.
    • setChannelNum

      public void setChannelNum(int num)
    • getChannelNum

      public int getChannelNum()
      Returns the channel index.
      Returns:
      the channel index.
    • setSessionNum

      public void setSessionNum(int num)
    • getSessionNum

      public int getSessionNum()
      Returns the number of sessions.
      Returns:
      the number of sessions.
    • setGroupNum

      public void setGroupNum(int num)
    • getGroupNum

      public int getGroupNum()
      Returns the number of groups.
      Returns:
      the number of groups.
    • setCreationTime

      public void setCreationTime(String time)
    • getCreationTime

      public String getCreationTime()
      Returns the user registration date and time.
      Returns:
      the user registration date and time.
    • setKeepAliveTime

      public void setKeepAliveTime(int nSecond)
    • getKeepAliveTime

      public int getKeepAliveTime()
      Returns the keep-alive time.
      Returns:
      the keep-alive time.
    • addSessionInfo

      public boolean addSessionInfo(CMSessionInfo si)
    • removeSessionInfo

      public boolean removeSessionInfo(String sname)
    • removeAllSessionInfoObjects

      public void removeAllSessionInfoObjects()
    • findSessionInfo

      public CMSessionInfo findSessionInfo(String sname)
    • getSessionInfoList

      public Vector<CMSessionInfo> getSessionInfoList()
      Returns the list of CMSessionInfo objects.
      Returns:
      the list of CMSessionInfo objects.
    • addGroupInfo

      public boolean addGroupInfo(CMGroupInfo gi)
    • removeGroupInfo

      public boolean removeGroupInfo(String gname)
    • removeAllGroupInfoObjects

      public void removeAllGroupInfoObjects()
    • findGroupInfo

      public CMGroupInfo findGroupInfo(String gname)
    • getGroupInfoList

      public Vector<CMGroupInfo> getGroupInfoList()
      Returns the list of CMGroupInfo objects.
      Returns:
      the list of CMGroupInfo objects.
    • getByteNum

      protected int getByteNum()
      Overrides:
      getByteNum in class CMEvent
    • marshallBody

      protected void marshallBody()
      Specified by:
      marshallBody in class CMEvent
    • unmarshallBody

      protected void unmarshallBody(ByteBuffer msg)
      Specified by:
      unmarshallBody in class CMEvent