-
Notifications
You must be signed in to change notification settings - Fork 0
Working with Xasu
Xasu works like a state machine. Its status can be checked in the Status
property of the Xasu tracker.
When Xasu awakes, it starts in the Uninitialized
state. In this state traces could be enqueued but they won't be submitted.
To initialize Xasu there are three different posibilities: using AutoStart, using the Init
method and using the Init
method with custom configuration. Later in this page you can see more details on these topics.
During initialization, Xasu will create the different Trace Processors (https://github.com/e-ucm/xasu/wiki/Working-Modes) and initialize the Authorization protocols (https://github.com/e-ucm/xasu/wiki/Authorization-protocols).
If everything initializes correctly, Xasu will enter in Working
state, where it is able to receive and process traces.
To send the traces, Xasu uses a asynchronous queue and a processing loop that is called every Processing Time
seconds.
Finally, when the session finalizes, Xasu has to be finalized before closing the application. This finalization is required in order to flush the remaining traces or upload the pending backups. After finalization ends, Xasu will be in Finalized
state.
If any error happens in any of the steps, Xasu will enter in Errored
state, and details about the error can be found in the Status
property.
The diagram below ilustrates the state machine diagram:
By default, Xasu starts up in a Idle (Created) state. In this state, Xasu is still in a blank state and is not ready to handle any traces.
To initialize it, there are threepossibilities:
- AutoStart using the configuration file
- Manual start using the configuration file (recommended)
- Manual start using the scripting API
The following diagram illustrates the parts involved in the Tracker initialization.
Please note that Authorization initialization may require the game to open browser windows or perform redirections (in WebGL).
To use AutoStart just check the AutoStart
property in XasuTracker from the GameObject Inspector.
To initialize Xasu using the configuration file located in the StreamingAssets folder you just have to call to.
await Xasu.Instance.Init();
Note that "Init" is an asynchronous task and thus await is the preferred method to continue after initialization.
To initialize Xasu using the scripting API you have to mannually create the TrackerConfig object and pass it to the Init function.
await Xasu.Instance.Init(new TrackerConfig
{
Online = true,
LRSEndpoint = "https://my.lrs.endpoint/",
AuthProtocol = "basic",
AuthParameters = new Dictionary<string, string>
{
{ "username", "your-username" },
{ "password", "your-password" }
}
});
Before the game is closed, Xasu has to be finalized manually so its processors (online, offline or backup) perform their final tasks.
These tasks include:
- Flushing all the queues in all processors.
- Sending all the online/fallback pending traces to the LRS (forcely requires internet connection to continue).
- Submitting the trace backup to the backup endpoint.
- Closing all the opened logs and connections.
To finalize Xasu, the Finalize function is used. The finalization progress can be measured using the IProgress interface.
var progress = new Progress<float>();
progress.ProgressChanged += (_, p) =>
{
Debug.Log("Finalization progress: " + p);
};
await Xasu.Instance.Finalize(progress);
Debug.Log("Tracker finalized");
Application.Quit();