Destroy Connection on Exit Game Mode Event


I added a TCP connection to an external server, to my CActor class. Later, I want the actor object to receive some update information through this connection. But when I exit the game mode, it still receive broadcast packet from the server. Well, I put the receiving function on a detached thread. It receive and read packets inside a loop which take a bool parameter isKeepRecv to continue running. isKeepRecv is set to true on CActor::init(). The problem is when should I change isKeepRecv to false so the thread can end itself? I want to change it on exit game mode event, but I don't know whether the enum code for such event even exists. Then I tried to change the isKeepRecv to false in ~CActor destructor but it doesn't change anything. When I put a breakpoint in the destructor, no break happens. It seems that the destructor itself has never been called. It would be great also if someone can explain to me the flow diagram of cryengine. I am getting a hard time trying to break it down and understand it.

Thank you :D

PS: English is not my first language, so forgive me if you get difficulties understanding my post :)

Re: Destroy Connection on Exit Game Mode Event

The destructor should get called, is it a virtual destructor?
There is an event in the SystemListener called ESYSTEM_EVENT_FULL_SHUTDOWN and ESYSTEM_EVENT_FAST_SHUTDOWN.

Although this may not be garunteed to fire if the process is terminated in certain ways. It may be better to have a timeout style timer to automatically close the thread if there has been no information from the main thread for x seconds.
CRYENGINE Technical Community Manager
Here to help the community and social channels grow and thrive.

My personal belongings;
Beginner Guides | My GitHub | Splash Plugin

Who is online

Users browsing this forum: No registered users and 0 guests