I have a client socket running in a separate thread, which is started from a playercontroller. After the thread starts, it communicates with a server throughout the lifespan of the game. It will from time to time receive data over the socket which is relevant for the playercontroller. What is the most effective and good-practice way of receiving this data in the playercontroller?
I managed to set up events that is triggered in the client socket thread, and bound to functions in the playercontroller, which are fired when the socket receives data, but haven’t yet managed to send data with the events, which is the strategy I opt for.
Firstly, is this possible, and if so how? Secondly, is this a good strategy, when it comes to thread safety and performance ?
Hope I made my question somewhat clear.