Exemplo n.º 1
0
        protected virtual void OnCommandReceived(SystemCommandModel theCmd)
        {
            SystemCommandEnum theEnum;

            Enum.TryParse(theCmd.Name, true, out theEnum);

            if (theEnum == SystemCommandEnum.None)
            {
                return;
            }

            var paramList = new List <KeyValuePair <string, object> >();

            paramList.Add(new KeyValuePair <string, object>("targetId", theCmd.TargetId));
            if (theCmd.NewPreference.HasValue)
            {
                paramList.Add(new KeyValuePair <string, object>("preference", theCmd.NewPreference));
            }

            CommandReceived?.Invoke(this, new CommandReceivedEventArgs
            {
                Command    = theEnum,
                Parameters = paramList
            });
        }
Exemplo n.º 2
0
        public void SendCommand(string deviceId, SystemCommandModel cmd)
        {
            var msg = JsonConvert.SerializeObject(cmd);

            _sbTasks.Add(_serviceClt.SendAsync(deviceId, new Message(Encoding.UTF8.GetBytes(msg))));
        }