private static void AsyncOpenClient(object credentials) { EditorWindow window = (credentials as object[])[0] as EditorWindow; AbstractTcpClient clientProvider = (credentials as object[])[1] as AbstractTcpClient; string address = (string)(credentials as object[])[2]; int port = (int)(credentials as object[])[3]; Action <Client> onComplete = (credentials as object[])[4] as Action <Client>; Client client = clientProvider.CreateClient(address, port); try { if (client != null) { Utility.RegisterIntervalCallback(ConnectionsManager.Update, 0); ConnectionsManager.clients.Add(client); string server = address + ':' + port; NGServerInstance instance = ConnectionsManager.udpListener.Find(server); if (instance == null) { instance = ConnectionsManager.udpListener.AddServer(server, server); } instance.users.Add(window); instance.client = client; } onComplete(client); } catch (Exception ex) { InternalNGDebug.LogException(ex); InternalNGDebug.LogError("Connection on " + address + ":" + port + " failed."); InternalNGDebug.LogError("Make sure your firewall allows TCP connection on " + port + "."); InternalNGDebug.LogError("Check if Stripping Level is not set on \"Use micro mscorlib\"."); InternalNGDebug.LogError("Try to connect Unity Profiler to guarantee the device is reachable."); InternalNGDebug.LogError("Find more tips at: https://bitbucket.org/Mikilo/neguen-tools/wiki/Home#markdown-header-31-guidances"); } }
public static Thread OpenClient(EditorWindow user, AbstractTcpClient clientProvider, string address, int port, Action <Client> onComplete) { string server = address + ':' + port; NGServerInstance instance = ConnectionsManager.udpListener.Find(server); if (instance != null && instance.client != null) { instance.users.Add(user); onComplete(instance.client); return(null); } else { Thread connectingThread = new Thread(ConnectionsManager.AsyncOpenClient) { Name = "Connecting Client" }; connectingThread.Start(new object[] { user, clientProvider, address, port, onComplete }); return(connectingThread); } }