Hello,
I am developing a Plugin that exposes a network API.
The main entry point of this API is a plain C++ object named Client that represents a connection to a server.
Once the API user has created the Client (there usually is only one), I want this Client to persist across levels (the goal is to keep the connection open). Destruction of the Client should only occur if the user explicitly asks for it.
So far, I have found two ways to achieve this:
- Store the Client directly in the plugin’s module object (the one that inherits from IModuleInterface).
- Store the Client in a custom UObject, which is added to the root set when created.
Both these options have worked fine so far, but they share a common problem: when using Play in Editor, the Client is kept alive after the Play session ends, which I do not want.
I am looking for a non-intrusive way to prevent the Client object from outliving a Play in Editor session.
By non-intrusive, I mean that I want it to be transparent to the user of my plugin (i.e. they should not have to create a custom GameInstance to hold a reference to the Client, etc.).
Is this at all possible? Thanks in advance.