Esempio n. 1
0
        public void Register([NotNull] ISignalReceiver receiver)
        {
            if (receiver == null)
            {
                throw new ArgumentNullException("receiver");
            }

            int key = receiver.Id;

            if (!ReceiverLookup.ContainsKey(key))
            {
                ReceiverLookup[key] = new List <ISignalReceiver>();
            }
            List <ISignalReceiver> list = ReceiverLookup[key];

            if (list.Contains(receiver))
            {
                return;
            }
            list.Add(receiver);

            List <SignalPacket> packetList;

            if (m_SignalsLastFrame.TryGetValue(key, out packetList))
            {
                foreach (SignalPacket packet in packetList)
                {
                    receiver.Receive(packet.Sender, packet.Data);
                    packet.NoReceivers = false;
                }
            }
        }
Esempio n. 2
0
 public static IObservable <TSignal> Receive <TSignal, TParameter>(this ISignalReceiver <TSignal> signalReceiver, TParameter parameter)
     where TSignal : ISignal <TParameter>
 {
     return(signalReceiver.Receive().Where(signal => Equals(signal.Parameter, parameter)));
 }