Destroy Connection on Exit Game Mode Event

#1
Hello!

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

#2
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.
Uniflare
CRYENGINE Technical Community Manager
Here to help the community and social channels grow and thrive.

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

Re: Destroy Connection on Exit Game Mode Event

#3
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.
is the destructor automatically called when the game exit? I tried to call the close connection function inside the destructor but it still gave no effect. I figured the receiving thread must be finished on its own first before the connection can be properly closed, so I used isKeepRecv, a boolean type var to change the receiving state so when the value is false the thread will be completed on its own. I finally found a way to change the value of isKeepRecv by using the onAction method. I created new action in action map beforehand. This also can be done by utilzing IInputEventListener though. Anyway this problem has been already solved. Thank you for your response, at least it supplied me with new information, especially about the SystemListener.

Who is online

Users browsing this forum: No registered users and 2 guests