public GameServer(bool autoConnect, int port, int broadCastPort, string netGroup) { maxPlayer = AppCfg.expose.MaxPlayer; waitConnectTime = AppCfg.expose.WaitConnectTime; maxEnterSceneTime = ServerCfg.MaxEnterSceneTime; host = new TcpHost(); curPlayer = 1; host.SetHost(port, maxPlayer); this.autoConnect = autoConnect; if (autoConnect) { IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ipa in IpEntry.AddressList) { if (ipa.AddressFamily == AddressFamily.InterNetwork) { localIP = ipa.ToString(); break; } } syncIpConnection = new UdpBase(broadCastPort, "SyncIP_Host", false); broadcastSelfData = Encoding.UTF8.GetBytes(Application.version + "|" + localIP.ToString() + "|" + netGroup); broadcastSelf = true; } gameStatus = GameStatus.WaitConnect; startUpTime = Time.time; Debug.LogWarning("部署服务器成功"); }