What is the lifetime of IOnlineSubsystem and it's SessionInterface?

What are the lifetimes of these online system objects? I’m working on a basic lobby manager class, and looking at ShooterGame for some examples. ShooterGame is constantly checking to see if they are valid. If I check once during initialization, can I be guaranteed that they will be around for the lifetime of my GameInstance object?

Hi Brock,

ShooterGame is just being safe with the validity checks. It’s always possible that a call to IOnlineSubsystem::Get() could return null if no OSS modules are found, which can happen if they’re not compiled in to your project (such as if don’t specify dependencies in Build.cs files). If you can guarantee that an appropriate OSS module will exist for your project, it should be valid for the entire time between calls to FOnlineSubsystemModule::GetOnlineSubsystem() (called by IOnlineSubsystem::Get()) and FOnlineSubsystemModule::DestroyOnlineSubsystem() (called by IOnlineSubsystem::Destroy() and IOnlineSubsystem::ReloadDefaultSubsystem()).

The pattern for the standard OSS implementations is to create their interface objects (including the session interface) in their Init() function and destroy them in their Shutdown() function. Just be careful because not all subsystems may implement every interface, and I can’t guarantee that all future and/or third-party OSS implementations will continue to follow the same pattern.