/// <summary> /// Close th econnection to the server /// </summary> /// <param name="client"></param> public void Disconnect(AsapiServer.Client client) { try { transport.Close(); } catch (TApplicationException x) { } }
/// <summary> /// Establish a connection to the server (ARE) /// </summary> /// <param name="ipAddress">IP-Address of the ARE</param> /// <param name="port">Port to connect</param> /// <returns>A ASAPI-client object</returns> public AsapiServer.Client Connect(string ipAddress, int port, int timeOutParam) { int timeOut = 10000; if (timeOutParam == -1) { // read socket timeout from the ini-file try { IniFile ini = null; if (File.Exists(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini")) { ini = new IniFile(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\asterics.ini"); } else if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini")) { ini = new IniFile(AppDomain.CurrentDomain.BaseDirectory + "asterics.ini"); } if (ini != null) { timeOut = int.Parse(ini.IniReadValue("ARE", "socket_timeout")); if (timeOut < 100) { timeOut = 3000; } } } catch (Exception) { } } else { timeOut = timeOutParam; } try { transport = new TSocket(ipAddress, port, timeOut); // set socket timeout to 10000ms protocol = new TBinaryProtocol(transport); client = new AsapiServer.Client(protocol); transport.Open(); return(client); } catch (Exception) { //catch (TApplicationException x) { //throw e; return(null); } }