Enigma Client Events

Work on the client portion of the session library has been slow mostly due to my crazy work schedule. It is hard to dig into code when you never know when your going to get called to do a service call. I finished a recent programming job for one of my actual clients and sub-contracted work has slowed down as of late so I made some decent progress today. For the record I would rather business pick back up though because slow weeks are tight budget weeks.

Anyway down to business although the current approach works just fine on the server side of things (mostly because it is basically single threaded still) the client side will need something a little different. The problem is that although the session manager will keep track of the state there are certain things that have to happen when some events happen. For example when the map is changed the session library just has to change the map Id in the user object and reset the map object(server sends new data). The problem is that the client will need to load the new map. The question becomes how will the client know to load the new map. I could keep an internal state and compare it on each frame but that is both expensive and inefficient because state will be stored in multiple locations. The obvious solution at least as far as I can tell is to go with an event driven architecture. That means having callback functions in game objects and have an event manager call them. At which point the objects can access game state and adjust scene-graph state to match.

Now that idea should work, however there is one notable catch. To prevent cross threading issues I will need to make sure the event queue is thread-safe and that the events are actually called from the graphics engine's thread. The reason is that some graphics engines have the requirement that some functions have to be called from the same thread that initialized the engine. So to make this work what I plan to do is call a "DoEvents" method from the main render loop which should work nicely. That model also still allow the rendering to be decoupled from the network latency because the network thread can be polling for updates while the game is rendering and just update the scene on the next pass.

If memory serves there is a inter-process queue in the boost libraries. I may use that or create methods that lock a mutex and modify the queue. I will also need to create event classes as well as event listener classes. If I do this correctly tying Enigma into a graphics engine should be a piece of cake by comparison at least.

Alright that's all thanks for reading.


Popular posts from this blog

VK9 - Milestone13 Completed

VK9 - Milestone16 Completed

VK9 - Milestone23 Completed