public class Session
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CONN_PORT |
static int |
PROTOCOL_VERSION |
| Constructor and Description |
|---|
Session(java.lang.String address,
int port,
java.lang.String deviceId,
java.lang.String loginName,
java.lang.String password) |
Session(java.lang.String address,
int port,
java.lang.String deviceId,
java.lang.String loginName,
java.lang.String password,
boolean useEncryption) |
Session(java.lang.String address,
java.lang.String deviceId,
java.lang.String loginName,
java.lang.String password) |
| Modifier and Type | Method and Description |
|---|---|
void |
connect()
Connect to server.
|
void |
disconnect()
Disconnect from server
|
protected void |
executeSimpleCommand(int command)
Execute simple commands (without arguments and only returning RCC)
|
protected void |
finalize() |
NXCPMessage |
newMessage(int code)
Create new NXCP message with unique id
|
void |
pushDciData(DciPushData[] data)
Push data to server.
|
void |
pushDciData(long nodeId,
long dciId,
java.lang.String value)
Push value for single DCI.
|
void |
pushDciData(java.lang.String nodeName,
java.lang.String dciName,
java.lang.String value)
Push value for single DCI.
|
void |
reportDeviceStatus(java.net.InetAddress address,
GeoLocation location,
int flags,
int batteryLevel)
Report basic current status of the device.
|
void |
reportDeviceSystemInfo(java.lang.String vendor,
java.lang.String model,
java.lang.String osName,
java.lang.String osVersion,
java.lang.String serialNumber,
java.lang.String userId)
Report basic system information about mobile device.
|
void |
sendMessage(NXCPMessage msg)
Send message to server
|
void |
setCommandTimeout(int commandTimeout)
Set command execution timeout in milliseconds.
|
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) |
public static final int DEFAULT_CONN_PORT
public static final int PROTOCOL_VERSION
public Session(java.lang.String address,
java.lang.String deviceId,
java.lang.String loginName,
java.lang.String password)
address - deviceId - loginName - password - public Session(java.lang.String address,
int port,
java.lang.String deviceId,
java.lang.String loginName,
java.lang.String password)
address - port - deviceId - loginName - password - public Session(java.lang.String address,
int port,
java.lang.String deviceId,
java.lang.String loginName,
java.lang.String password,
boolean useEncryption)
address - port - deviceId - loginName - password - useEncryption - protected void finalize()
finalize in class java.lang.Objectpublic void sendMessage(NXCPMessage msg) throws java.io.IOException, MobileAgentException
msg - Message to sentjava.io.IOException - in case of socket communication failureMobileAgentException - in case of encryption errorpublic NXCPMessage waitForMessage(int code, long id, int timeout) throws MobileAgentException
code - id - timeout - MobileAgentExceptionpublic NXCPMessage waitForMessage(int code, long id) throws MobileAgentException
code - id - MobileAgentExceptionpublic NXCPMessage waitForRCC(long id) throws MobileAgentException
id - MobileAgentExceptionpublic NXCPMessage waitForRCC(long id, int timeout) throws MobileAgentException
id - timeout - NXCExceptionMobileAgentExceptionpublic final NXCPMessage newMessage(int code)
code - message codeprotected void executeSimpleCommand(int command)
throws java.io.IOException,
MobileAgentException
command - Command codejava.io.IOExceptionMobileAgentExceptionpublic void connect()
throws java.io.IOException,
java.net.UnknownHostException,
MobileAgentException
java.io.IOExceptionjava.net.UnknownHostExceptionMobileAgentExceptionpublic void disconnect()
public void setCommandTimeout(int commandTimeout)
commandTimeout - public void pushDciData(DciPushData[] data) throws java.io.IOException, MobileAgentException
data - push datajava.io.IOException - if socket I/O error occursMobileAgentException - if NetXMS server returns an error or operation was timed outpublic void pushDciData(long nodeId,
long dciId,
java.lang.String value)
throws java.io.IOException,
MobileAgentException
nodeId - node IDdciId - DCI IDvalue - value to pushjava.io.IOException - if socket I/O error occursMobileAgentException - if NetXMS server returns an error or operation was timed outpublic void pushDciData(java.lang.String nodeName,
java.lang.String dciName,
java.lang.String value)
throws java.io.IOException,
MobileAgentException
nodeName - node namedciName - DCI namevalue - value to pushjava.io.IOException - if socket I/O error occursMobileAgentException - if NetXMS server returns an error or operation was timed outpublic void reportDeviceSystemInfo(java.lang.String vendor,
java.lang.String model,
java.lang.String osName,
java.lang.String osVersion,
java.lang.String serialNumber,
java.lang.String userId)
throws java.io.IOException,
MobileAgentException
vendor - vendor name (like "HTC")model - device model (like "Desire A8181")osName - operating system name (like "Android")osVersion - operating system version (like "2.2")serialNumber - device serial numberuserId - user id, if available (can be null)java.io.IOException - if socket I/O error occursMobileAgentException - if NetXMS server returns an error or operation was timed outpublic void reportDeviceStatus(java.net.InetAddress address,
GeoLocation location,
int flags,
int batteryLevel)
throws java.io.IOException,
MobileAgentException
address - current IP address of the device (may be null if not known)location - current device location (may be null if not known)flags - batteryLevel - current battery level, -1 if not known or not applicablejava.io.IOException - if socket I/O error occursMobileAgentException - if NetXMS server returns an error or operation was timed outCopyright © 2014. All Rights Reserved.