Skip to main content

Know when the game client is offline

Loss of Internet connectivity is detected when the EOS SDK reports that the local user is disconnected from the Epic Online Services backend. Once Internet connectivity is lost, the plugin will periodically try to reconnect to the backend. Once it succeeds, the plugin reports that Internet connectivity is restored.

To listen for changes in Internet connectivity, use the OnConnectionStatusChanged event:

Register for connection status notifications

void UMyClass::HandleConnectionStatusChanged(
const FString &ServiceName,
EOnlineServerConnectionStatus::Type LastConnectionState,
EOnlineServerConnectionStatus::Type ConnectionState)
{
// Do something with ConnectionState
// The value will always be either Connected or NotConnected
}

void UMyClass::ExecuteRegisterConnectionStatusChanged()
{
// Get the online subsystem.
auto OSS = Online::GetSubsystem(this->GetWorld());
if (OSS == nullptr)
{
// Online subsystem is not available.
return;
}

// Register the HandleConnectionStatusChanged delegate
OSS->AddOnConnectionStatusChangedDelegate_Handle(FOnConnectionStatusChanged::FDelegate::CreateUObject(
this,
&UMyClass::HandleConnectionStatusChanged));
}