Ejemplo n.º 1
0
 public async Task UpdateStateAsync(ObjectStateUpdateGroup objectstateupdategroup, CancellationToken token)
 {
     try
     {
         await _rpcClient.InvokeAsync("UpdateState", objectstateupdategroup, _maxRpcDuration, CancellationToken.None);
     }
     catch (JsonRpcException e)
     {
         _logger.Error(e, "Calling method UpdateStateAsync failed: {0}. Exception:", e.RpcMessage);
         throw;
     }
     catch (Exception e)
     {
         _logger.Error(e, "Calling method UpdateStateAsync failed with exception: ");
     }
 }
Ejemplo n.º 2
0
        public void UpdateState(ObjectStateUpdateGroup objectstateupdategroup)
        {
            var updategroup = objectstateupdategroup.Update;

            foreach (var update in updategroup)
            {
                var objects = update.Objects;
                var states  = update.States;
                if (objects.Ids.Length != states.Length)
                {
                    throw new JsonRpcException((int)ProtocolErrorCode.Error, "List of object ids and list of states were of different lengths.", null);
                }
                if (objects.Ids.Length == 0)
                {
                    throw new JsonRpcException((int)ProtocolErrorCode.Error, "List of objects is empty.", null);
                }
                UpdateStateCalled?.Invoke(this, update);
            }
        }