protected void processMessage(IncomingAggreGateCommand cmd, OutgoingAggreGateCommand ans) { var messageCode = cmd.getMessageCode(); if (messageCode.Length > 1) { throw new SyntaxErrorException(Cres.get().getString("clInvalidMsgCode") + messageCode); } var code = messageCode[0]; if ((code != AggreGateCommand.MESSAGE_CODE_START) && (!startMessageReceived)) { Logger.getLogger(Log.CLIENTS).debug("Can't process message: start message was not received yet"); ans.constructReply(cmd.getId(), AggreGateCommand.REPLY_CODE_DENIED); return; } switch (code) { case AggreGateCommand.MESSAGE_CODE_START: processMessageStart(cmd, ans); break; case AggreGateCommand.MESSAGE_CODE_OPERATION: processMessageOperation(cmd, ans); break; default: throw new SyntaxErrorException(Cres.get().getString("clUnknownMsgCode") + messageCode[0]); } }
public void processMessageStart(IncomingAggreGateCommand cmd, OutgoingAggreGateCommand ans) { var version = Int32.Parse(cmd.getParameter(AggreGateCommand.INDEX_PROTOCOL_VERSION)); Logger.getLogger(Log.CLIENTS).debug("Processing start command, client protocol version: " + version); if (version == ClientCommandUtils.CLIENT_PROTOCOL_VERSION) { ans.constructReply(cmd.getId(), AggreGateCommand.REPLY_CODE_OK); startMessageReceived = true; } else { ans.constructReply(cmd.getId(), AggreGateCommand.REPLY_CODE_DENIED); } }
public void processOperationGetVar(String id, Context con, String name, OutgoingAggreGateCommand ans) { var vd = con.getVariableDefinition(name); if (vd == null) { ans.constructReply(id, AggreGateCommand.REPLY_CODE_DENIED, Cres.get().getString("conVarNotAvail") + name); return; } var result = con.getVariable(name, callerController); ans.constructReply(id, AggreGateCommand.REPLY_CODE_OK); ans.addParam(result.encode(createClassicEncodingSettings(vd.getFormat() != null))); }
public void processOperationSetVar(String id, Context con, String name, String encodedValue, OutgoingAggreGateCommand ans) { var vd = con.getVariableDefinition(name); if (vd == null) { ans.constructReply(id, AggreGateCommand.REPLY_CODE_DENIED, Cres.get().getString("conVarNotAvail") + name); return; } var settings = new ClassicEncodingSettings(false, vd.getFormat()); var value = new DataTable(encodedValue, settings, true); con.setVariable(name, callerController, value); ans.constructReply(id, AggreGateCommand.REPLY_CODE_OK); }
public void processOperationRemoveEventListener(String id, String context, String name, Int32?listener, OutgoingAggreGateCommand ans) { Logger.getLogger(Log.CLIENTS).debug("Removing listener for event '" + name + "' of context '" + context + "'"); var cel = createListener(listener); removeMaskListener(context, name, cel); ans.constructReply(id, AggreGateCommand.REPLY_CODE_OK); }
public void processOperationCallFunction(String id, Context con, String name, String encodedParameters, OutgoingAggreGateCommand ans) { Logger.getLogger(Log.CLIENTS).debug("Calling function '" + name + "' of context '" + con.getPath() + "'"); var fd = con.getFunctionDefinition(name); if (fd == null) { ans.constructReply(id, AggreGateCommand.REPLY_CODE_DENIED, Cres.get().getString("conFuncNotAvail") + name); return; } var settings = new ClassicEncodingSettings(false, fd.getInputFormat()); var parameters = new DataTable(encodedParameters, settings, true); var result = con.callFunction(name, callerController, parameters); ans.constructReply(id, AggreGateCommand.REPLY_CODE_OK); ans.addParam(result.encode(createClassicEncodingSettings(fd.getOutputFormat() != null))); }
public OutgoingAggreGateCommand processCommand(IncomingAggreGateCommand cmd) { var ans = new OutgoingAggreGateCommand(); try { var commandCode = cmd.getParameter(AggreGateCommand.INDEX_COMMAND_CODE); if (commandCode.Length > 1) { throw new AggreGateException(Cres.get().getString("clInvalidCmdCode") + commandCode); } switch (commandCode[0]) { case AggreGateCommand.COMMAND_CODE_MESSAGE: processMessage(cmd, ans); break; default: throw new AggreGateException(Cres.get().getString("clUnknownCmdCode") + commandCode[0]); } } catch (ContextSecurityException ex) { Logger.getLogger(Log.CLIENTS).info("Access denied while processing command '" + cmd + "': ", ex); ans.constructReply(cmd.getId(), AggreGateCommand.REPLY_CODE_DENIED); } catch (Exception ex) { Logger.getLogger(Log.CLIENTS).info("Error processing command '" + cmd + "': ", ex); ans.constructReply(cmd.getId(), AggreGateCommand.REPLY_CODE_ERROR, ex.Message ?? ex.ToString(), getErrorDetails(ex)); } return(ans); }