Ejemplo n.º 1
0
        protected void TransmitTo(IObjectReceiver receiver, Dictionary <string, object> Objects)
        {
            receiver.Receive(Objects);

            /*
             * if (ControllerFrom.IsMasteredBy(ControllerDest, out FullPrefix))
             * {
             *  //put header
             *  Dictionary<string, object> toSend = new Dictionary<string, object>();
             *  foreach (KeyValuePair<string, object> o in Objects)
             *      toSend.Add(FullPrefix + o.Key, o.Value);
             *  receiver.Receive(toSend);
             * }
             * else if (ControllerDest.IsMasteredBy(ControllerFrom, out FullPrefix))
             * {
             *  //delete header
             *  int fullPrefixLength = FullPrefix.Length;
             *  Dictionary<string, object> toSend = new Dictionary<string, object>();
             *  foreach (KeyValuePair<string, object> o in Objects)
             *  {
             *      if (o.Key.IndexOf(FullPrefix) == 0)
             *          toSend.Add(o.Key.Substring(fullPrefixLength), o.Value);
             *      else
             *          toSend.Add(o.Key, o.Value);
             *  }
             *  receiver.Receive(toSend);
             * }
             * else
             *  throw new Exception("Error. Components located at unrelated Controllers can not communicate.");*/
        }
Ejemplo n.º 2
0
        public Guid Subscribe(Type message, IObjectReceiver receiver)
        {
            var sub = new Subscriber
            {
                Receiver = receiver
            };

            if (!_subCache.ContainsKey(message))
            {
                _subCache.Add(message, new List <Subscriber>());
            }

            _subCache[message].Add(sub);
            return(sub.Id);
        }