// 连接服务器 public void ConnectServer(string ip, int port, Action <Connection, string> callback) { NC.Close(); Debug.Log("ConnectServer " + ip + ":" + port); #if UNITY_IPHONE && !UNITY_EDITOR String newServerIp = ""; AddressFamily newAddressFamily = AddressFamily.InterNetwork; IPv6SupportMidleware.getIPType(ip, port.ToString(), out newServerIp, out newAddressFamily); UnityEngine.Debug.Log("ConnectServer use IPv6 ? " + (newAddressFamily == AddressFamily.InterNetworkV6 ? "Yes" : "No")); NC.Connect2Peer(newServerIp, port, newAddressFamily, (Connection conn, string reason) => { ResetAllConnection(conn); callback(conn, reason); }); #else NC.Connect2Peer(ip, port, (Connection conn, string reason) => { ResetAllConnection(conn); callback(conn, reason); }); #endif }