Пример #1
0
        /// <summary>
        /// Handles the group communication message.
        /// </summary>
        private void Handle(NsMessage <GeneralGroupCommunicationMessage> value, bool isRegistration = false)
        {
            // This is mainly used to handle the case should ObserverContainer
            // decide to trigger handlers concurrently for a single message.
            if (isRegistration)
            {
                // Process the registration message
                _registrationMessage = value;
            }
            else if (_registrationMessage != null && value == _registrationMessage)
            {
                // This means that we've already processed the message.
                // Ignore this message and discard the reference.
                _registrationMessage = null;
                return;
            }

            var gcMessage = value.Data.First();

            IObserver <NsMessage <GeneralGroupCommunicationMessage> > observer;

            if (!_observers.TryGetValue(NodeObserverIdentifier.FromMessage(gcMessage), out observer))
            {
                throw new InvalidOperationException();
            }

            observer.OnNext(value);
        }
 /// <summary>
 /// Compare equality of instance fields.
 /// </summary>
 private bool Equals(NodeObserverIdentifier other)
 {
     return(_type == other.Type &&
            _groupName.Equals(other.GroupName) &&
            _operatorName.Equals(other.OperatorName));
 }
Пример #3
0
 /// <summary>
 /// Registers a node associated with the Task.
 /// </summary>
 public void RegisterNodeObserver <T>(NodeMessageObserver <T> observer)
 {
     _observers.Add(NodeObserverIdentifier.FromObserver(observer), observer);
 }