연결 상태 유지
Prevent connection timeouts by regularly sending messages to the Relay server.
읽는 시간 1분최근 업데이트: 한 달 전
Relay 서버는 일정 기간 동안 활동이 없으면 자동으로 클라이언트의 연결을 해제합니다. Relay가 클라이언트의 연결을 해제할 때까지의 기본 TTL(Time to Live)은 10초입니다. 호스트가 혼자 있을 때(
BINDCONNECTUpdate()NetworkManagerStartClientStartHostNetworkDriver//Call the below regularly, e.g., in Monobehaviour.Update()void Example_KeepingConnectionAlive(){ // Update the NetworkDrivers regularly to ensure the host/player is kept online. if (HostDriver.IsCreated && isRelayServerConnected) { HostDriver.ScheduleUpdate().Complete(); //Accept incoming client connections while (HostDriver.Accept() != default(NetworkConnection)) { Debug.Log("Accepted an incoming connection."); } } if (PlayerDriver.IsCreated && clientConnection.IsCreated) { PlayerDriver.ScheduleUpdate().Complete(); //Resolve event queue NetworkEvent.Type eventType; while ((eventType = clientConnection.PopEvent(PlayerDriver, out _)) != NetworkEvent.Type.Empty) { if (eventType == NetworkEvent.Type.Connect) { Debug.Log("Client connected to the server"); } else if (eventType == NetworkEvent.Type.Disconnect) { Debug.Log("Client got disconnected from server"); clientConnection = default(NetworkConnection); } } }}