private void DoConnect(Servers.Entry server) { connecting = server; try { IPAddress.Parse(server.ip); ZSteamMatchmaking.instance.QueueServerJoin($"{server.ip}:{server.port}"); } catch (FormatException) { Mod.Log.LogInfo($"Resolving: {server.ip}"); resolveTask = Dns.GetHostEntryAsync(server.ip); } }
void Update() { if (resolveTask != null) { if (resolveTask.IsFaulted) { Mod.Log.LogError($"Error resolving IP: {resolveTask.Exception}"); if (resolveTask.Exception is AggregateException) { ShowError((resolveTask.Exception as AggregateException).InnerException.Message); } else { ShowError(resolveTask.Exception.Message); } resolveTask = null; connecting = null; } else if (resolveTask.IsCanceled) { resolveTask = null; connecting = null; } else if (resolveTask.IsCompleted) { foreach (var addr in resolveTask.Result.AddressList) { if (addr.AddressFamily == AddressFamily.InterNetwork) { Mod.Log.LogInfo($"Resolved: {addr}"); resolveTask = null; ZSteamMatchmaking.instance.QueueServerJoin($"{addr}:{connecting.port}"); return; } } resolveTask = null; connecting = null; ShowError("Server DNS resolved to no valid addresses"); } } }
public void AbortConnect() { connecting = null; resolveTask = null; }
public void JoinServerFailed() { ShowError("Server connection failed"); connecting = null; }