use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method setAttributeForCurrentUser.
/**
* Set custom attribute for currently logged in user. Server will allow to change
* only attributes whose name starts with dot.
*
* @param name Attribute's name
* @param value New attribute's value
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void setAttributeForCurrentUser(final String name, final String value) throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_SET_CURRENT_USER_ATTR);
msg.setField(NXCPCodes.VID_NAME, name);
msg.setField(NXCPCodes.VID_VALUE, value);
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method listMappingTables.
/**
* Get list of all configured mapping tables.
*
* @return List of MappingTableDescriptor objects
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public List<MappingTableDescriptor> listMappingTables() throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_LIST_MAPPING_TABLES);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_ELEMENTS);
final List<MappingTableDescriptor> list = new ArrayList<MappingTableDescriptor>(count);
long varId = NXCPCodes.VID_ELEMENT_LIST_BASE;
for (int i = 0; i < count; i++) {
list.add(new MappingTableDescriptor(response, varId));
varId += 10;
}
return list;
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method getServerVariables.
/**
* Get server configuration variables
*
* @return The server variables
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public Map<String, ServerVariable> getServerVariables() throws IOException, NXCException {
NXCPMessage request = newMessage(NXCPCodes.CMD_GET_CONFIG_VARLIST);
sendMessage(request);
final NXCPMessage response = waitForRCC(request.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_VARIABLES);
final HashMap<String, ServerVariable> varList = new HashMap<String, ServerVariable>(count);
long id = NXCPCodes.VID_VARLIST_BASE;
for (int i = 0; i < count; i++, id += 10) {
ServerVariable v = new ServerVariable(response, id);
varList.put(v.getName(), v);
}
count = response.getFieldAsInt32(NXCPCodes.VID_NUM_VALUES);
for (int i = 0; i < count; i++) {
ServerVariable var = varList.get(response.getFieldAsString(id++));
if (var != null)
var.addPossibleValue(response, id);
id += 2;
}
return varList;
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method wakeupNode.
/**
* Wakeup node by sending wake-on-LAN magic packet. Either node ID or
* interface ID may be given. If node ID is given, system will send wakeup
* packets to all active interfaces with IP address.
*
* @param objectId node or interface ID
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void wakeupNode(final long objectId) throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_WAKEUP_NODE);
msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) objectId);
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
use of org.netxms.base.NXCPMessage in project netxms by netxms.
the class NXCSession method deleteAlarmCategory.
/**
* Delete alarm category in DB
* @param id of alarm category
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public void deleteAlarmCategory(long id) throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_DELETE_ALARM_CATEGORY);
msg.setFieldInt32(NXCPCodes.VID_CATEGORY_ID, (int) id);
sendMessage(msg);
waitForRCC(msg.getMessageId());
}
Aggregations