Libmpc.MpcConnection.Connect C# (CSharp) Method

Connect() public method

Connects to the MPD server who's IPEndPoint was set in the Server property.
If no IPEndPoint was set to the Server property.
public Connect ( ) : void
return void
        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);
        }

Same methods

MpcConnection::Connect ( IPEndPoint server ) : void