예제 #1
0
 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);
     }
 }
예제 #2
0
 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");
         }
     }
 }
예제 #3
0
 public void AbortConnect()
 {
     connecting  = null;
     resolveTask = null;
 }
예제 #4
0
 public void JoinServerFailed()
 {
     ShowError("Server connection failed");
     connecting = null;
 }