1.4.1 |
Documentation for the Unity C# Library
|
There are 4 functions used for manipulating session and data reporting:
All events used for when these functions are called are the same for when calling Authentication functionality. To see how to use the events, see Handling Authentication API Responses in the Authentication page.
All Session Event responses do not contain important information other than to indicate a failure to reach the server or if there was an error in the format of the data once it reached the server.
The approach in the Unity Apex SDK is done through specific Success and Fail unity events.
If you want more information on the data types in the events, check out the sections below.
httpresponsemessage HttpResponseMessage failureresponse FailureResponse
A session is one complete play-through of single scenario. Different modules handle this in different ways, but the main idea is that a session should be the scenario itself, not the process of selecting an experience.
Some modules have a lobby that a user loads into after authentication and return to after running through a scenario. Time in the lobby should not count towards any session- the session begins when you choose an experience from the lobby, and the session ends when you finish the experience, either by completing it, or using a menu option to return to the lobby.
Other modules just have a front end menu, but the concept is the same- the session begins once you have selected the experience from the menu.
Every time a user enters a scenario, (whether directly from the login screen, from a lobby, from a front-end menu, or from any other system you have set up), you need to call ApexSystem::JoinSession(). Similarly, once they have finished a scenario you need to call ApexSystem::CompleteSession().
The ApexSystem::JoinSession() function should be called every time the user starts a new session.
FALSE
if there is no logged in user. Otherwise returns TRUE
.The ApexSystem::JoinSession() function has 2 optional parameters:
scenarioID:String
- Sets the ApexSystem::scenarioID, which is then used as part of the id
property of the object
object. If this is not set, then whatever the ApexSystem::scenarioID was previously set to will be used.contextExtension:Extension
- Allows you to include any custom extensions in the context object. This is used to include any additional information you want to report that is not in the standard JoinSession() report. See Extensions for more details.PixoVR::Apex::ApexSystem::OnJoinSessionSuccess() - This Delegate is called when the platform indicates that the new session was started.
response:HttpResponseMessage
- Contains the HTTP response messagePixoVR::Apex::ApexSystem::OnJoinSessionFailed() - Called when the user failed to start a new session.
response:FailureResponse
- Contains the error code and error message for why the user failed to join the session.In the Example Code section, you'll see C# examples on how to bind to the event delegates.
The ApexSystem::CompleteSession() function should be called every time the user completes a session.
It:
FALSE
if there is no logged in user or current session.The ApexSystem::CompleteSession() function has 1 required parameter and 2 optional parameters:
currentSessionData:SessionData
- Contains scoring information as well as if the session was completed.contextExtension:Extension
- Use this parameter to add data to the Context in the xAPI structure.resultExtension:Extension
Use this parameter to add data to the Result in the xAPI structure.PixoVR::Apex::ApexSystem::OnCompleteSessionSuccess() - Called when the platform indicates that the session was completed.
response:HttpResponseMessage
- Contains the HTTP response message.PixoVR::Apex::ApexSystem::OnCompleteSessionFailed() - Called when the user either had not started a session before calling this or passed invalid information.
response:FailureResponse
- Contains the error code and error message for why the user failed to join the session.In the Example Code section, you'll see C# examples on how to bind to the event delegates.
The ApexSystem::SendSimpleSessionEvent() function is how you send any simplified data to Apex during a session.
It:
FALSE
if there is no logged in user, if ApexSystem::JoinSession() has not been called to start a session, if the action
is null or an empty string.The ApexSystem::SendSimpleSessionEvent() function has 2 required parameters and 1 optional parameter:
action:string
- The name of the event that has occurred within the module. The action
is the name of the Verb.targetObject:string
- The name of the object or person that the action
is taking place against or on. The targetObject
is the name of the Activity and used in the activity ID.contextExtension:Extension
- Use this parameter to add data to the Context in the xAPI structure.SendSimpleSessionEvent returns FALSE
if there action
is null or an emptry string. In all other cases, TRUE
will be returned.
PixoVR::Apex::ApexSystem::OnSendEventSuccess() - Called when the platform indicates that the session event was sent successfully.
response:HttpResponseMessage
- Contains the HTTP response message.PixoVR::Apex::ApexSystem::OnSendEventFailed() - Called when the platform indicates that the session event was not received successfully, had invalid data or the server was not reachable.
response:FailureResponse
- Contains the error code and error message for why the user failed to send the session event.In the Example Code section, you'll see C# examples on how to bind to the event delegates.
The ApexSystem::SendSessionEvent()::SendSessionEvent() function is how you send any full or custom set of data to Apex during a session.
It:
FALSE
if there is no logged in user, if ApexSystem::JoinSession() has not been called to start a session, or if any of the following members in eventStatement
are null:eventStatement.verb
eventStatement.verb.id
eventStatement.target
The ApexSystem::SendSessionEvent() function has 1 required parameter:
eventStatement:Statement
- Provides all the necessary data to generate the xAPI statement.The eventStatement
is an xAPI Statement, which contains the whole structure within the required xAPI Spec.
PixoVR::Apex::ApexSystem::OnSendEventSuccess() - Called when the platform indicates that the session event was sent successfully.
response:HttpResponseMessage
- Contains the HTTP response message.PixoVR::Apex::ApexSystem::OnSendEventFailed() - Called when the platform indicates that the session event was not received successfully, had invalid data or the server was not reachable.
response:FailureResponse
- Contains the error code and error message for why the user failed to send the session event.In the Example Code section, you'll see C# examples on how to bind to the event delegates.