private void StateTransitionHandler(object o, ElapsedEventArgs e) { // if we're not connected, don't bother doing anything involving the network. if (!connected) { return; } if ((state == State.Idle || state == State.NeedTransmit) && hard_failures > 2) { hard_failures = 0; } // and address changes in our engine state switch (state) { case State.Idle: if (queue.Any()) { state = State.NeedTransmit; RaiseSubmissionStart(queue.Count); } else if (current_now_playing_request != null) { // Now playing info needs to be sent NowPlaying(current_now_playing_request); } else { StopTransitionHandler(); RaiseSubmissionEnd(); } break; case State.NeedTransmit: if (DateTime.Now > next_interval) { TransmitQueue(); } break; case State.Transmitting: case State.WaitingForResponse: // nothing here break; } }
public IQueue Filter(IQueue queue) { return(queue.Any(log => log.Type == RecordType.Record && _minimalLogLevel <= log.Severity && log.Severity != LogLevel.None) ? queue : queue.CloneEmpty()); }