private const float _HEART_BEAT_INTERVAL = 60f; // 心跳时间间隔,服务器检测用的间隔比客户端实际间隔要多一些, LobbyServer的间隔要再多一些,因为客户端与大厅之间的消息少 #region 初始化 void Awake() { if (Instance != null) { Debug.LogError("LobbyManager is Singleton! Cannot be created again!"); } Instance = this; Players = new Dictionary <SocketAsyncEventArgs, PlayerInfo>(); Rooms = new Dictionary <long, RoomInfo>(); RoomServers = new Dictionary <SocketAsyncEventArgs, RoomServerInfo>(); // 读取数据表 CsvDataManager = gameObject.AddComponent <CsvDataManager>(); CsvDataManager.LoadDataAll(); var csv = CsvDataManager.Instance.GetTable("server_config_lobby"); if (csv != null) { // 房间服务器监听地址, 按理说监听地址, 不能由外部指定, 但是对于云服务器, 是没有本地地址的, 只能外部指定 _server.Address = csv.GetValue(1, "LobbyServerAddress"); _server.Port = csv.GetValueInt(1, "LobbyServerPort"); } // 限制帧速率 Application.targetFrameRate = 30; }
void Awake() { if (Instance != null) { Debug.LogError("ClientManager is Singleton! Cannot be created again!"); } Instance = this; LobbyManager.gameObject.SetActive(false); // 读取数据表 CsvDataManager = gameObject.AddComponent <CsvDataManager>(); CsvDataManager.LoadDataAll(); // 限制帧速率 Application.targetFrameRate = 30; }