Libmpc.MpcConnection.Idle C# (CSharp) Method

Idle() public method

Puts the client in idle mode for the given subsystems
public Idle ( Mpc subsystems ) : void
subsystems Mpc The subsystems to listen to.
return void
        public void Idle(Mpc.Subsystems subsystems)
        {
            StringBuilder subs = new StringBuilder();
              foreach (Mpc.Subsystems s in Enum.GetValues(typeof(Mpc.Subsystems))){
            if (s != Mpc.Subsystems.All && (subsystems & s) != 0)
              subs.AppendFormat(" {0}", s.ToString());
              }
              string command = string.Format("idle {0}", subs.ToString());

              try {
            while (true){
              this.CheckConnected();
              m_SocketManager.WriteLine(command);
              MpdResponse res = this.readResponse();

              Mpc.Subsystems eventSubsystems = Mpc.Subsystems.None;
              foreach (string m in res.Message){
            List<string> values = res.getValueList();
            foreach (string sub in values){
              Mpc.Subsystems s = Mpc.Subsystems.None;
              if (Enum.TryParse<Mpc.Subsystems>(sub, out s)){
                eventSubsystems |= s;
              }
            }
              }

              if (eventSubsystems != Mpc.Subsystems.None && this.OnSubsystemsChanged != null)
            this.OnSubsystemsChanged(this, eventSubsystems);
            }
              }
              catch (Exception) {
            try {
              this.Disconnect();
            }
            catch (Exception) { }
              }
        }