use of org.netxms.base.NXCPMessageReceiver in project netxms by netxms.
the class Session method receiverThread.
private void receiverThread() {
// 256KB, 4MB
final NXCPMessageReceiver messageReceiver = new NXCPMessageReceiver(262144, 4194304);
while (!Thread.currentThread().isInterrupted()) {
try {
final NXCPMessage message = messageReceiver.receiveMessage(socket.getInputStream(), null);
if (message != null) {
if (message.getMessageCode() != NXCPCodes.CMD_KEEPALIVE) {
log.debug("Request: " + message.toString());
}
final MessageProcessingResult result = session.processMessage(message);
if (result.response != null) {
if (message.getMessageCode() != NXCPCodes.CMD_KEEPALIVE) {
log.debug("Reply: " + result.response.toString());
}
sendMessage(result.response);
if (result.file != null) {
log.debug("File data found, sending");
FileInputStream s = null;
try {
s = new FileInputStream(result.file);
sendFileStream(message.getMessageId(), s);
} catch (IOException e) {
log.error("Unexpected I/O exception while sending rendered file");
}
if (s != null)
s.close();
result.file.delete();
}
}
}
} catch (IOException e) {
log.info("Communication error", e);
stop();
} catch (NXCPException e) {
log.info("Invalid message received", e);
stop();
}
}
}
Aggregations