Inheritance: IDisposable
Exemple #1
0
        /// <summary>
        /// Connects to the MPD server who's IPEndPoint was set in the Server property.
        /// </summary>
        /// <exception cref="InvalidOperationException">If no IPEndPoint was set to the Server property.</exception>
        public void Connect()
        {
            if (this.ipEndPoint == null)
            throw new InvalidOperationException("Server IPEndPoint not set.");

              if (this.Connected)
            throw new AlreadyConnectedException();

              if (m_SocketManager != null) {
            m_SocketManager.Dispose();
              }

              m_SocketManager = new SocketManager();
              m_SocketManager.Connect(ipEndPoint);

              string firstLine = m_SocketManager.ReadLine();
              if (!firstLine.StartsWith(FIRST_LINE_PREFIX)) {
            this.Disconnect();
            throw new InvalidDataException("Response of mpd does not start with \"" + FIRST_LINE_PREFIX + "\".");
              }
              this.version = firstLine.Substring(FIRST_LINE_PREFIX.Length);

              //m_SocketManager.WriteLine(string.Empty);
              //this.readResponse();

              MpdResponse response = Exec("commands");
              m_Commands = response.getValueList();

              if (this.OnConnected != null)
            this.OnConnected.Invoke(this);
        }
Exemple #2
0
 private void ClearConnectionFields()
 {
     m_SocketManager = null;
       this.version = null;
 }
Exemple #3
0
 private void ClearConnectionFields()
 {
     m_SocketManager = null;
     this.version    = null;
 }