Class EntityWatchdog

Class EntityWatchdog#

Class Documentation#

class xbe.sdk.Utils.EntityWatchdog#

EntityWatchdog is a utility service that provides a simple way to retrieve automatic updates for a registered EntityBase object. When registering a callback function for a given entity object the service will begin monitoring the backend service for changes to the object. If a change has been detected the callback function that was registered will be called containing the newly modified entity object. Note that it will not modify the existing object instance used to register the callback. It is the responsibility of the implementor to merge any changes from the new instance to the old one if desired.

Also note that the registered callback function will be executed from a different thread where safety is not guaranteed.It is the responsibility of the implementor to enforce any thread-safety needed for the data in

question.

Public Functions

delegate void Callback<T> (T obj)#

Defines a callback function that will be notified when a monitored entity has updated.

Tparam T:

The type of entity to watch.

Param obj:

The updated entity instance.

EntityWatchdog (IAPIClient apiClient, Configuration config)#

Initializes the utility using the provided Configuration and ApiClient instances.

Param apiClient:

Param config:

void Shutdown ()#

Stops watching all entity objects and cleans up the service.

void Watch<T> (T entity, Callback<T> callback)#

Registers the provided callback function to be notified whenever an update is detected for the specified entity object. Note that the callback function will be notified from a different thread of execution.It is recommended that thread-safe handling of the provided data is implemented in the callback function itself.

Tparam T:

Param entity:

The entity object to watch.

Param callback:

The function call call when an update to the entity object is detected.

void Unwatch<T> (T entity, Callback<T> callback)#

Removes the registered callback with the given id for the specified entity object.

Tparam T:

Param entity:

The entity object to stop watching.

Param callback:

The callback to be removed

Properties

int NumWatchedEntities { get; set; }#

The number of currently watched entities.