Ejemplo n.º 1
0
        public void StartListeningTo(string topicName, string recordKey, string fieldName, int topicId)
        {
            // Ensure we only listen to the topic once - this allows clients to call
            // us multiple times
            lock (lockObject)
            {
                // Add the recordKey/fieldName to topicId mapping and start subscribing
                var topicFieldKey = new TopicKey(recordKey, fieldName);

                if (!topicNameToTopicID.Contains(topicFieldKey))
                {
                    topicNameToTopicID.Add(topicFieldKey, topicId);
                    topicIDToTopicName.Add(topicId, topicFieldKey);
                }

                if (listeningToTopics.Contains(topicName))
                {
                    return;
                }

                if (CreateTopicListener(topicName))
                {
                    listeningToTopics.Add(topicName);
                }
            }
        }
Ejemplo n.º 2
0
        public void RemoveTopic(int topicID)
        {
            if (topicIDToTopicName.Contains(topicID))
            {
                TopicKey topicFieldKey = (TopicKey)topicIDToTopicName[topicID];

                topicNameToTopicID.Remove(topicFieldKey);
                topicIDToTopicName.Remove(topicID);
            }
        }
Ejemplo n.º 3
0
        private void RegisterGenericChange(string fieldName, string fieldValue)
        {
            var topicFieldKey = new TopicKey(fieldName, fieldName);

            if (_topicNameToTopicId.Contains(topicFieldKey))
            {
                var topicId = (int)_topicNameToTopicId[topicFieldKey];
                // remove incase it is already present
                UpdateChangedTopic(topicId, fieldValue);
            }
        }
Ejemplo n.º 4
0
        private void RegisterGenericChange(string fieldName, string fieldValue)
        {
            TopicKey topicFieldKey = new TopicKey(fieldName, fieldName);

            if (topicNameToTopicID.Contains(topicFieldKey))
            {
                int topicID = (int)topicNameToTopicID[topicFieldKey];
                // remove incase it is already present
                changedTopics.Remove(topicID);
                changedTopics.Add(topicID, fieldValue);
            }
        }
Ejemplo n.º 5
0
        private void AddAdminFieldUpdates(string topicKey, IDictionary parsedMessage)
        {
            var accountPair = "account=" + parsedMessage["account"];

            foreach (var fieldName in _accountAdminFields)
            {
                var recordKey = BuildPositionLookupKey(accountPair, fieldName);

                var topicFieldKey = new TopicKey(recordKey, fieldName);

                if (_topicNameToTopicId.Contains(topicFieldKey))
                {
                    var topicId = (int)_topicNameToTopicId[topicFieldKey];
                    // remove incase it is already present
                    UpdateChangedTopic(topicId, LookupValue(topicKey, fieldName));
                }
            }
        }
Ejemplo n.º 6
0
        private void AddAdminFieldUpdates(string topicKey, IDictionary parsedMessage)
        {
            string accountPair = "account=" + parsedMessage["account"];

            foreach (string fieldName in AccountAdminFields)
            {
                string recordKey = BuildPositionLookupKey(accountPair, fieldName);

                TopicKey topicFieldKey = new TopicKey(recordKey, fieldName);

                if (topicNameToTopicID.Contains(topicFieldKey))
                {
                    int topicID = (int)topicNameToTopicID[topicFieldKey];
                    // remove incase it is already present
                    changedTopics.Remove(topicID);
                    changedTopics.Add(topicID, lookupValue(topicKey, fieldName));
                }
            }
        }
Ejemplo n.º 7
0
        private void RegisterChange(string topicKey, IDictionary parsedMessage)
        {
            // for each topic and record, add them to the list of changed topics
            lock (_lockObject)
            {
                foreach (string fieldName in parsedMessage.Keys)
                {
                    var topicFieldKey = new TopicKey(topicKey, fieldName);

                    if (_topicNameToTopicId.Contains(topicFieldKey))
                    {
                        var topicId = (int)_topicNameToTopicId[topicFieldKey];
                        // remove incase it is already present
                        UpdateChangedTopic(topicId, (string)parsedMessage[fieldName]);
                    }
                }
            }
            // add in the admin fields
            AddAdminFieldUpdates(topicKey, parsedMessage);
        }
Ejemplo n.º 8
0
        private void RegisterChange(string topicKey, IDictionary parsedMessage)
        {
            // for each topic and record, add them to the list of changed topics
            lock (lockObject)
            {
                foreach (string fieldName in parsedMessage.Keys)
                {
                    TopicKey topicFieldKey = new TopicKey(topicKey, fieldName);

                    if (topicNameToTopicID.Contains(topicFieldKey))
                    {
                        int topicID = (int)topicNameToTopicID[topicFieldKey];
                        // remove incase it is already present
                        changedTopics.Remove(topicID);
                        changedTopics.Add(topicID, parsedMessage[fieldName]);
                    }
                }
            }
            // add in the admin fields
            AddAdminFieldUpdates(topicKey, parsedMessage);
        }
Ejemplo n.º 9
0
        public override bool Equals(Object other)
        {
            TopicKey otherKey = other as TopicKey;

            return(topicName == otherKey.topicName && fieldName == otherKey.fieldName);
        }