Exemplo n.º 1
0
 public DispatchableInstance(DispatchableType type, string name, Guid id, DispatchableSource source)
 {
     Type   = type;
     Name   = name;
     Id     = id;
     Source = source;
 }
 private void ValueDispatched(DispatchableType type, Guid nodeId, object value)
 {
     if (_nodeMap.ContainsKey(nodeId))
     {
         _nodeMap[nodeId].DispatchValue(value);
     }
 }
Exemplo n.º 3
0
 public virtual IDictionary <Guid, object> GetValues(DispatchableType type)
 {
     lock (_lock)
     {
         if (NodeValues.ContainsKey(type))
         {
             return(NodeValues[type]);
         }
     }
     return(new Dictionary <Guid, object>());
 }
Exemplo n.º 4
0
        public object GetValue(DispatchableType type, Guid id)
        {
            lock (_lock)
            {
                if (NodeValues.ContainsKey(type) && NodeValues[type].ContainsKey(id))
                {
                    return(NodeValues[type][id]);
                }
            }

            return(null);
        }
Exemplo n.º 5
0
        public void RegisterDispatch(DispatchableType type, Guid id, Action <IDispatchable, object> callback)
        {
            if (!_registrationMap.ContainsKey(type))
            {
                _registrationMap.Add(type, new ConcurrentDictionary <Guid, IList <Action <IDispatchable, object> > >());
            }
            if (!_registrationMap[type].ContainsKey(id))
            {
                _registrationMap[type].Add(id, new List <Action <IDispatchable, object> >());
            }

            _registrationMap[type][id].Add(callback);
        }
Exemplo n.º 6
0
        public async Task RegisterDispatch(DispatchableType type, Guid id, Action <IDispatchable, object> callback)
        {
            var topic = $"{RemoteTopicConstants.DISPATCHER_TOPIC}/{type}/{id}";

            _subscriptions.Add(topic);

            await _mqttClient.SubscribeAsync(topic, MQTTnet.Protocol.MqttQualityOfServiceLevel.AtLeastOnce);

            if (!_registrationMap.ContainsKey(type))
            {
                _registrationMap.Add(type, new ConcurrentDictionary <Guid, IList <Action <IDispatchable, object> > >());
            }
            if (!_registrationMap[type].ContainsKey(id))
            {
                _registrationMap[type].Add(id, new List <Action <IDispatchable, object> >());
            }

            _registrationMap[type][id].Add(callback);
        }
Exemplo n.º 7
0
 // Register a dispatcher from the control thread.
 public void RegisterDispatcher(DispatchableType dispatchableType, Dispatcher dispatcher)
 {
     _dispatchingMap[dispatchableType] = dispatcher;
 }
Exemplo n.º 8
0
        public async Task DispatchValue(DispatchableType type, Guid id, object value)
        {
            await _dataHub.Clients.Group("All").SendAsync("dispatchValue", type, id, value);

            await _dataHub.Clients.Group(id.ToString()).SendAsync("dispatchValue", type, id, value);
        }