Sam, why we wrote destroy function for the Session. we use TSharePtr<> (which is the same as smart pointer in C++) and it must be deleted automatically whenever it’s not usable
The lifetime of active sessions is managed by the IOnlineSession manager. If you don’t destroy it, it will continue to live. Not sure where we are using a TSharePtr<> to manage it?
IOnlineSessionPtr SessionInterface = Subsystem->GetSessionInterface();
and IOnlineSessionPtr is the typedef of TSharePtr<>
and my question is the same TSharePtr<> must be destroyed when we quit the game, why we wrote destroy function?
For my reference, this is the commit we are talking about: https://github.com/UnrealMultiplayer/3_Steam_Multiplayer/commit/4e7f183aaa93fd4d732be6d238625ff910293ce4
I think the confusion is between the session interface and an actual session. The IOnlineSession type is the interface to a manager object. This will automatically be tracked by the TSharedPtr.
However, we use this manager object to create and destroy actual sessions by their session name. Which we do on lines 98 and 78 respectively. We do not have a pointer to theses sessions, we only have their names. And so we have to explicitly manage their lifetime.
Now it’s clear. Thank you Sam
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.