Example #1
0
        private void MessageConnectionMessageReceived(object sender, MessageReceivedEventArgs e)
        {
            if (AbortFlag)
            {
                return;
            }

            Logger.DebugFormat(Constants.ClientNameFormat, Settings.Name, e.JsonMessage.GetHeader());

            _messages.Add(e);
            if (e.DataType == typeof(SlotCollection))
            {
                foreach (var slot in _messages.SlotCollection)
                {
                    _messageConnection.SendCommand(String.Format(CultureInfo.InvariantCulture, Constants.FahClientSlotOptions, slot.Id));
                }
            }
            else if (e.DataType == typeof(LogRestart) ||
                     e.DataType == typeof(LogUpdate))
            {
                bool createNew = e.DataType == typeof(LogRestart);
                if (createNew)
                {
                    _fahLog.Clear();
                }

                var logFragment = (LogFragment)e.TypedMessage;
                _fahLog.AddRange(logFragment.Value.Split('\n').Where(x => x.Length != 0));
                WriteToLocalFahLogCache(logFragment.Value, createNew);

                if (_messages.LogRetrieved)
                {
                    _messageConnection.SendCommand("queue-info");
                }
            }
        }