# Principle¶

## Event subscription ¶

To react to a particular event, you first have to subscribe to it. To do so, you must first create a proxy to ALMemory, then call the subscribeToEvent method to subscribe to the desired event. If you want to stop calling the callback, use the unsubscribeToEvent method. Each event has a particular name.

To create the memory proxy, you can use the module’s broker directly instead of the IP adress (this only works if you are inside a module). You then indicate to which event you want to subscribe, and the callback function that will be called somewhere.


AL::ALMemoryProxy memProxy = AL::ALMemoryProxy(getBroker());
memProxy.subscribeToEvent("eventName", "ModuleForCallback", "callbackFunctionName");


## Callback function ¶

When subscribing to the event, you specify the callback function and the module from where it comes. This means the callback function has to be bound somewhere. You cannot give any argument to the callback function.