コード例 #1
0
        public Boolean removeEventListener(String name, ContextEventListener contextEventListener,
                                           Boolean sendRemoteCommand)
        {
            try
            {
                init();

                Log.CONTEXT_EVENTS.debug("Removing listener for event '" + name + "' from context '" + this.getPath() + "'");

                var res = base.removeEventListener(name, contextEventListener);

                var ed = getEventData(name);

                if (sendRemoteCommand && ed != null && ed.getListeners().Count == 0)
                {
                    var hashCode = contextEventListener.getListenerCode();

                    if (!notManageRemoteListenersBoolean)
                    {
                        this.controller.sendCommandAndCheckReplyCode(ClientCommandUtils.removeEventListenerOperation(this.getPath(), name, hashCode));
                    }
                }

                return(res);
            }
            catch (Exception ex)
            {
                var msg = String.Format(Cres.get().getString("conErrRemovingListener"), name, this.getPath());
                throw new InvalidOperationException(msg + ": " + ex.Message, ex);
            }
        }
コード例 #2
0
        private void addRemoteListener(String ename, ContextEventListener contextEventListener)
        {
            var hashCode = contextEventListener.getListenerCode();

            if (hashCode == null && AUTO_LISTENED_EVENTS.Contains(ename))
            {
                return;
            }

            if (!notManageRemoteListenersBoolean)
            {
                controller.sendCommandAndCheckReplyCode(ClientCommandUtils.addEventListenerOperation(this.getPath(), ename, hashCode));
            }
        }
コード例 #3
0
 public override DataTable callRemoteFunction(String name, TableFormat outputFormat, DataTable parameters)
 {
     try
     {
         var ans =
             controller.sendCommandAndCheckReplyCode(ClientCommandUtils.callFunctionOperation(this.getPath(), name, parameters.encode(controller.createClassicEncodingSettings(true))));
         return(decodeRemoteDataTable(outputFormat, ans.getEncodedDataTableFromReply()));
     }
     catch (Exception ex)
     {
         Log.CONTEXT_FUNCTIONS.debug("Error calling function '" + name + "' of context '" + this.getPath() + "'", ex);
         throw new ContextException(ex.Message, ex);
     }
 }
コード例 #4
0
 protected override Boolean setVariableImpl(VariableDefinition def, CallerController <CallerData> caller,
                                            RequestController <RequestData> request, DataTable value)
 {
     try
     {
         controller.sendCommandAndCheckReplyCode(ClientCommandUtils.setVariableOperation(this.getPath(), def.getName(), value.encode(controller.createClassicEncodingSettings(true))));
         return(true);
     }
     catch (Exception ex)
     {
         Log.CONTEXT_VARIABLES.debug("Error setting veriable '" + def.getName() + "' of context '" + this.getPath() + "'", ex);
         throw new ContextException(ex.Message, ex);
     }
 }
コード例 #5
0
        protected virtual Boolean connectImpl()
        {
            processor = new AsyncDeviceCommandProcessor(this, device, commandTimeout);

            processor.start();

            var ans = sendCommand(ClientCommandUtils.startMessage());

            if (!ans.getReplyCode().Equals(AggreGateCommand.REPLY_CODE_OK))
            {
                throw new RemoteDeviceErrorException(Cres.get().getString("devUncompatibleVersion"));
            }

            return(true);
        }
コード例 #6
0
 private void sendRemoveListener(String context, String eventString, ContextEventListener listener)
 {
     try
     {
         getController().sendCommandAndCheckReplyCode(ClientCommandUtils.removeEventListenerOperation(context,
                                                                                                      eventString,
                                                                                                      listener.
                                                                                                      getListenerCode
                                                                                                          ()));
     }
     catch (Exception ex)
     {
         var msg = String.Format(Cres.get().getString("conErrRemovingListener"), eventString, context);
         throw new InvalidOperationException(msg + ": " + ex.Message, ex);
     }
 }
コード例 #7
0
 private IncomingAggreGateCommand sendGetVariable(String name)
 {
     return(this.controller.sendCommandAndCheckReplyCode(ClientCommandUtils.getVariableOperation(this.getPath(), name)));
 }