public void Disconnect() { IsPendingStartup = false; if (Client != null) { try { Client.Disconnect().GetAwaiter().GetResult(); } catch { } finally { Client = null; } EventLog.WriteEntry("Disconnected", EventLogEntryType.Warning); } }
public void Connect() { if (MasterServerAddress == null) { MasterServerAddress = OmenAPI.FindMasterServer().GetAwaiter().GetResult(); EventLog.WriteEntry("Got MasterServer " + MasterServerAddress); } if (MasterServerAddress != null && Client == null) { try { Client = new OmenMasterServerClient(); Client.Connect("ws://" + MasterServerAddress + ":666/", Settings).GetAwaiter().GetResult(); EventLog.WriteEntry("Connected", EventLogEntryType.Warning); IsPendingStartup = false; } catch (Exception) { Client = null; IsPendingStartup = true; } } }