giovedì 3 novembre 2016

Day 184: Unions

Today I tried to understand how to make the system exchange different types of packets. My original idea was to have a code_id at the beginning of each message, so that the recv could read that, and then depending on the code, another recv would read a different type of structure.
My networking professor suggested to use unions instead. I still think my idea is more bandwidth efficient because you only send the necessary data, but I decided to go with unions anyway to avoid two calls to recv and for a cleaner implementation.
So I implemented that and now the engine make full use of those. Nothing changed apparently, but now I can very easily add other types of packages, like a RequestTime one which will enable me to sync the time of network and clients.

Nessun commento:

Posta un commento