Call the pre exit function in AActor class


I am connected to a server in this AActor class. When I exit from the editor It doesn’t shut down the connection, nor can my server get the gist that the ue4 client is gone.

             if (recv == 0)

The last thing a client sends is a packet that's is empty. 

how can I invoke the Pre Exit function. So when I press escape/ quit game, it will send one final message to it's server before quitting game. That way my server can log the client out from database.

How do I call PREEXIT!

virtual void BeginDestroy() override;

void AMyActor::BeginDestroy()
	your logic code...

your can also override Destroyed

virtual void Destroyed() override;