org.netxms.api.client
Interface Session


public interface Session

Base client session interface. All client APIs for NetXMS based products expected to provide this interface.


Method Summary
 void addListener(SessionListener lst)
          Add notification listener
 void checkConnection()
          Send KEEPALIVE message.
 void connect()
          Connect to the server.
 void disconnect()
          Disconnect from server.
 java.lang.String getAttributeForCurrentUser(java.lang.String name)
          Get custom attribute for currently logged in user.
 java.lang.String getConnClientInfo()
           
 int getRecvBufferSize()
          Get receiver buffer size.
 java.lang.String getServerAddress()
          Get server address
 byte[] getServerId()
          Get NetXMS server UID.
 java.lang.String getServerTimeZone()
           
 java.lang.String getServerVersion()
          Get NetXMS server version.
 int getUserId()
          Get identifier of logged in user.
 java.lang.String getUserName()
          Get login name of currently logged in user
 int getUserSystemRights()
          Get system-wide rights of currently logged in user.
 boolean isConnected()
          Get connection state
 boolean isPasswordExpired()
           
 NXCPMessage newMessage(int code)
          Create new NXCP message with unique id
 void removeListener(SessionListener lst)
          Remove notification listener
 void setAttributeForCurrentUser(java.lang.String name, java.lang.String value)
          Set custom attribute for currently logged in user.
 void setCommandTimeout(int commandTimeout)
          Set command execution timeout.
 void setConnClientInfo(java.lang.String connClientInfo)
           
 void setRecvBufferSize(int recvBufferSize)
          Set receiver buffer size.
 NXCPMessage waitForMessage(int code, long id)
          Wait for message with specific code and id.
 NXCPMessage waitForMessage(int code, long id, int timeout)
          Wait for message with specific code and id.
 NXCPMessage waitForRCC(long id)
          Wait for CMD_REQUEST_COMPLETED message with given id using default timeout
 NXCPMessage waitForRCC(long id, int timeout)
          Wait for CMD_REQUEST_COMPLETED message with given id
 

Method Detail

addListener

void addListener(SessionListener lst)
Add notification listener

Parameters:
lst - Listener to add

removeListener

void removeListener(SessionListener lst)
Remove notification listener

Parameters:
lst - Listener to remove

waitForMessage

NXCPMessage waitForMessage(int code,
                           long id,
                           int timeout)
                           throws NetXMSClientException
Wait for message with specific code and id.

Parameters:
code - Message code
id - Message id
timeout - Wait timeout in milliseconds
Returns:
Message object
Throws:
NetXMSClientException - if message was not arrived within timeout interval

waitForMessage

NXCPMessage waitForMessage(int code,
                           long id)
                           throws NetXMSClientException
Wait for message with specific code and id.

Parameters:
code - Message code
id - Message id
Returns:
Message object
Throws:
NetXMSClientException - if message was not arrived within timeout interval

waitForRCC

NXCPMessage waitForRCC(long id)
                       throws NetXMSClientException
Wait for CMD_REQUEST_COMPLETED message with given id using default timeout

Parameters:
id - Message id
Returns:
received message
Throws:
NetXMSClientException - if message was not arrived within timeout interval or contains RCC other than RCC.SUCCESS

waitForRCC

NXCPMessage waitForRCC(long id,
                       int timeout)
                       throws NetXMSClientException
Wait for CMD_REQUEST_COMPLETED message with given id

Parameters:
id - Message id
timeout - Timeout in milliseconds
Returns:
received message
Throws:
NetXMSClientException - if message was not arrived within timeout interval or contains RCC other than RCC.SUCCESS

newMessage

NXCPMessage newMessage(int code)
Create new NXCP message with unique id

Parameters:
code - Message code
Returns:
New message object

connect

void connect()
             throws java.io.IOException,
                    java.net.UnknownHostException,
                    NetXMSClientException
Connect to the server.

Throws:
java.io.IOException
java.net.UnknownHostException
NetXMSClientException

disconnect

void disconnect()
Disconnect from server.


getRecvBufferSize

int getRecvBufferSize()
Get receiver buffer size.

Returns:
Current receiver buffer size in bytes.

setRecvBufferSize

void setRecvBufferSize(int recvBufferSize)
Set receiver buffer size. This method should be called before connect(). It will not have any effect after connect().

Parameters:
recvBufferSize - Size of receiver buffer in bytes.

getServerAddress

java.lang.String getServerAddress()
Get server address

Returns:
Server address

getUserName

java.lang.String getUserName()
Get login name of currently logged in user

Returns:
login name of currently logged in user

getServerVersion

java.lang.String getServerVersion()
Get NetXMS server version.

Returns:
Server version

getServerId

byte[] getServerId()
Get NetXMS server UID.

Returns:
Server UID

getServerTimeZone

java.lang.String getServerTimeZone()
Returns:
the serverTimeZone

getConnClientInfo

java.lang.String getConnClientInfo()
Returns:
the connClientInfo

setConnClientInfo

void setConnClientInfo(java.lang.String connClientInfo)
Parameters:
connClientInfo - the connClientInfo to set

setCommandTimeout

void setCommandTimeout(int commandTimeout)
Set command execution timeout.

Parameters:
commandTimeout - New command timeout

getUserId

int getUserId()
Get identifier of logged in user.

Returns:
Identifier of logged in user

getUserSystemRights

int getUserSystemRights()
Get system-wide rights of currently logged in user.

Returns:
System-wide rights of currently logged in user

isPasswordExpired

boolean isPasswordExpired()
Returns:
the passwordExpired

setAttributeForCurrentUser

void setAttributeForCurrentUser(java.lang.String name,
                                java.lang.String value)
                                throws java.io.IOException,
                                       NetXMSClientException
Set custom attribute for currently logged in user. Server will allow to change only attributes whose name starts with dot.

Parameters:
name - Attribute's name
value - New attribute's value
Throws:
java.io.IOException - if socket I/O error occurs
NetXMSClientException - if NetXMS server returns an error or operation was timed out

getAttributeForCurrentUser

java.lang.String getAttributeForCurrentUser(java.lang.String name)
                                            throws java.io.IOException,
                                                   NetXMSClientException
Get custom attribute for currently logged in user. If attribute is not set, empty string will be returned.

Parameters:
name - Attribute's name
Returns:
Attribute's value
Throws:
java.io.IOException - if socket I/O error occurs
NetXMSClientException - if NetXMS server returns an error or operation was timed out

isConnected

boolean isConnected()
Get connection state

Returns:
connection state

checkConnection

void checkConnection()
                     throws java.io.IOException,
                            NetXMSClientException
Send KEEPALIVE message. Return nothing is connection is fine, exception thrown otherwise

Throws:
java.io.IOException
NXCException
NetXMSClientException


Copyright © 2012. All Rights Reserved.