public void Disconnect() { if (m_client != null) { PrintLine("Commands Client Disconnecting"); m_client.Disconnect(); m_client = null; if (m_hil != null) { m_hil.Disconnect(); m_hil = null; } } }
public void Connect(string ip = "localhost", int id = 0, bool failIfApiVersionMsmatch = false) { if (IsConnected) { throw new Exception("Cannot connect. Already connected. Disconnect first."); } int port = 4820 + id; PrintLine("Connecting to " + ip + " port on " + port + "..."); m_client = new CmdClient(); m_client.Connect(ip, port); m_serverApiVersion = m_client.GetServerApiVersion(); if (ClientApiVersion != m_serverApiVersion) { string msg = "Client Api Version (" + ClientApiVersion + ") != Server Api Version (" + m_serverApiVersion + ")"; if (failIfApiVersionMsmatch) { throw new Exception(msg); } else { Console.WriteLine("Warning: " + msg); } } int hilPort = ((HilPortResult)CallCommand(new GetHilPort())).Port; m_hil = new HilClient(); m_hil.Connect(ip, hilPort); m_hil.IsVerbose = IsVerbose; m_client.IsVerbose = IsVerbose; }