Example #1
0
        private void HandleMessage(string message, MessageStreamListener listener)
        {
            // everything failed
            if (String.IsNullOrEmpty(message))
            {
                this.lastHash = null;
                this.RaiseConfigChanged(null);
                return;
            }

            // deserialize the buckets
            var jss = new JavaScriptSerializer();

            jss.RegisterConverters(KnownConverters);

            var config = jss.Deserialize <ClusterConfig>(message);

            // check if the config is the same as the previous
            // we cannot compare the messages because they have more information than we deserialize from them
            var configHash = config.GetHashCode();

            if (lastHash != configHash)
            {
                lastHash = configHash;
                this.RaiseConfigChanged(config);
                listener.UpdateNodes(config);
            }
            else if (log.IsDebugEnabled)
            {
                log.Debug("Last message was the same as current, ignoring.");
            }
        }
        private void HandleMessage(string message, MessageStreamListener listener)
        {
            // everything failed
            if (String.IsNullOrEmpty(message))
            {
                this.lastHash = null;
                this.RaiseConfigChanged(null);
                return;
            }

            // deserialize the buckets
            var jss = new JavaScriptSerializer();
            jss.RegisterConverters(KnownConverters);

            var config = jss.Deserialize<ClusterConfig>(message);

            // check if the config is the same as the previous
            // we cannot compare the messages because they have more information than we deserialize from them
            var configHash = config.GetHashCode();

            if (lastHash != configHash)
            {
                lastHash = configHash;
                this.RaiseConfigChanged(config);
                listener.UpdateNodes(config);
            }
            else if (log.IsDebugEnabled)
                log.Debug("Last message was the same as current, ignoring.");
        }