msempere/behaviours — pull request #1 by davidmoreno (2013-06-22 09:48:20+00:00)
Title: Finish use of circular buffer for server->client events.

Hi,

I finished the implementation of the circular queue and event passing from server to client.

To add new events just add a event_processor to main:

main.event_processors["my_event"]=function(data){ do_something(data.field) }

This should be done in a plugin. At server side just use:

manager->eventQueue.pushEvent("my_event", json_object);

There is a helper for the most common case of just one value to data:

manager->eventQueue.pushEvent("my_event", "key", "value");

This is used, for example on the node enter/exit at nodemanager.cpp:444.

On the implementation side the circular buffer is just a simple circular buffer. It does not have any knowledge of the start id. Also it is more generic and all code moved to the class template definition itself. The start_id has been moved to EventQueue, and synchronization resources were added. It is important the getJSONStringBlock that uses blocking (std::condition_variable), limiting the number of petitions.

LUA console and node/enter exit are migratd to this event framework and some legacy code was removed on both server and client.

Last, copyright notices were added. Please add them to any new file, with your name in it. If missing it is assumed from now on that you give your rights as BSD license (do whatever you want with the code, dont blame me).