6using System.Collections.Generic;
8using System.Text.RegularExpressions;
9using System.Threading.Tasks;
14using static UnityEngine.Audio.ProcessorInstance;
24 [DefaultExecutionOrder(-50)]
27 private static readonly
string TAG =
"ApexSystem";
44 set { Instance.moduleID = value; }
50 set { Instance.moduleName = value; }
55 get {
return Instance.moduleVersion; }
56 set { Instance.moduleVersion = value; }
62 set { Instance.scenarioID = value; }
67 get {
return Instance.currentActiveLogin; }
73 get {
return Instance.runSetupOnAwake; }
74 set { Instance.runSetupOnAwake = value; }
79 get {
return Instance.loginCheckModuleAccess; }
85 get {
return Instance.deviceSerialNumber; }
93 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Getting passed login token as {Instance.loginToken} in instance {Instance.gameObject.name}");
99 Debug.unityLogger.Log(LogType.Error,
TAG, $
"Setting passed login token to {value}");
100 Instance.loginToken = value;
106 get {
return Instance.optionalParameter; }
107 set { Instance.optionalParameter = value; }
112 get {
return Instance.currentExitTargetParameter; }
117 Instance.currentExitTargetParameter = value;
121 Instance.currentExitTargetParameter =
"";
124 if (
Instance.currentExitTargetParameter.Contains(
"://"))
137 get {
return Instance.targetTypeParameter; }
138 private set { Instance.targetTypeParameter = value; }
148 get {
return Instance.apexAPIHandler; }
151 [SerializeField, EndpointDisplay]
232 Debug.unityLogger.Log(LogType.Log,
TAG, $
"ApexSystem found on {gameObject.name}");
235 Debug.unityLogger.Log(LogType.Log,
TAG,
"Instance already initialized.");
238 var projectSettings = Resources.Load<Editor.PixoVRProjectSettings>(
"PixoVRProjectSettings");
239 if (projectSettings !=
null)
249#if UNITY_IOS || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
254 Debug.unityLogger.Log(LogType.Log,
TAG,
"Running on awake!");
258 DontDestroyOnLoad(gameObject);
259#if MANAGE_XR && !UNITY_EDITOR
260 Debug.unityLogger.Log(LogType.Log,
TAG,
"Using ManageXR");
266 async
void InitMXRSDK()
268 Debug.unityLogger.Log(LogType.Log,
TAG,
"Initializing the ManageXR SDK");
269 await MXRManager.InitAsync();
270 MXRManager.System.OnDeviceStatusChange += OnDeviceStatusChanged;
272 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Device serial set to {deviceSerialNumber}");
275 void OnDeviceStatusChanged(DeviceStatus newDeviceStatus)
278 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Device serial number changed to {deviceSerialNumber}");
285 if (!
string.IsNullOrEmpty(Application.absoluteURL))
301 Debug.unityLogger.Log(LogType.Log,
TAG,
"SetupPlatformConfiguration");
306 Debug.unityLogger.Log(LogType.Log,
TAG,
"Found pixoconfig.cnf");
310 if (configContent.Length > 0)
312 Debug.unityLogger.Log(LogType.Log,
TAG,
"Configuration is not empty.");
314 if (configData ==
null)
316 Debug.unityLogger.Log(LogType.Log,
TAG,
"Failed to deserialize the config.");
321 if (configData.
Platform.Contains(
"NA", StringComparison.CurrentCultureIgnoreCase))
323 if (configData.
Platform.Contains(
"Production", StringComparison.CurrentCultureIgnoreCase))
325 Debug.unityLogger.Log(LogType.Log,
TAG,
"NA Production platform target.");
329 if (configData.
Platform.Contains(
"Dev", StringComparison.CurrentCultureIgnoreCase))
331 Debug.unityLogger.Log(LogType.Log,
TAG,
"NA Dev platform target.");
335 if (configData.
Platform.Contains(
"Stage", StringComparison.CurrentCultureIgnoreCase))
337 Debug.unityLogger.Log(LogType.Log,
TAG,
"NA Stage platform target.");
341 else if (configData.
Platform.Contains(
"SA", StringComparison.CurrentCultureIgnoreCase))
343 Debug.unityLogger.Log(LogType.Log,
TAG,
"SA Production platform target.");
366 Debug.unityLogger.Log(LogType.Log,
TAG,
"Apex API Handler is not null!");
393 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Login Token: {(string.IsNullOrEmpty(PassedLoginToken) ? "<Null>
" : PassedLoginToken)}");
400 Debug.unityLogger.Log(LogType.Log,
TAG,
"ApexSystem::_ExitApplication");
401 if (nextExitApplication ==
null)
403 nextExitApplication =
"";
406 string returnTargetType =
"app";
408 if (nextExitApplication.Contains(
"://"))
410 returnTargetType =
"url";
413 Debug.unityLogger.Log(LogType.Log,
TAG,
"" + nextExitApplication +
" " + returnTargetType);
415 string parameters =
"";
417 Debug.unityLogger.Log(LogType.Log,
TAG,
"Building parameters for url.");
432 if (parameters.Length > 0)
438 if (nextExitApplication.Length > 0)
440 if (parameters.Length > 0)
442 parameters +=
"returntarget=" + nextExitApplication;
445 if (returnTargetType.Length > 0)
447 if (parameters.Length > 0)
449 parameters +=
"targettype=" + returnTargetType;
452 Debug.unityLogger.Log(LogType.Log,
TAG,
"Checking the return target parameter.");
456 Debug.unityLogger.Log(LogType.Log,
TAG,
"Had a valid return target parameter.");
459 Debug.unityLogger.Log(LogType.Log,
TAG,
"Return Target is a URL.");
462 if (!
string.IsNullOrEmpty(parameters))
464 if (!returnURL.Contains(
'?'))
469 returnURL += parameters;
471 Debug.unityLogger.Log(LogType.Log,
TAG,
"Custom Target: " + returnURL);
478 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Return Target is a package name. {CurrentExitTarget}");
480 List<string> keys =
new List<string>(),
481 values =
new List<string>();
483 Debug.unityLogger.Log(LogType.Log,
TAG,
"Adding pixo token.");
487 keys.Add(
"pixotoken");
492 keys.Add(
"pixotoken");
496 Debug.unityLogger.Log(LogType.Log,
TAG,
"Adding optional.");
500 keys.Add(
"optional");
504 Debug.unityLogger.Log(LogType.Log,
TAG,
"Adding return target.");
506 if (!
string.IsNullOrEmpty(nextExitApplication))
508 keys.Add(
"returntarget");
509 values.Add(nextExitApplication);
512 Debug.unityLogger.Log(LogType.Log,
TAG,
"Adding return target type.");
514 if (!
string.IsNullOrEmpty(returnTargetType))
516 keys.Add(
"targettype");
517 values.Add(returnTargetType);
531 return target.ToUrlString();
536 int targetValue = (int)target;
539 return apiTarget.ToUrlString();
563 Debug.unityLogger.Log(LogType.Warning,
TAG, $
"{moduleVersion} is an invalid module version.");
565 deviceID = SystemInfo.deviceUniqueIdentifier;
568 XRSettings.loadedDeviceName.Length > 0 ? XRSettings.loadedDeviceName : Application.platform.ToString();
569 clientIP = Utils.ApexUtils.GetLocalIP();
603 Debug.unityLogger.Log(LogType.Log,
TAG,
"Websocket connected successfully.");
608 Debug.unityLogger.Log(LogType.Error,
TAG,
"Websocket failed to connect with error: " + reason);
613 Debug.unityLogger.Log(LogType.Log,
TAG,
"Websocket received: " + data);
616 if (data.Contains(
"auth_code"))
622 if (data.Contains(
"Token", StringComparison.OrdinalIgnoreCase))
630 Debug.unityLogger.Log(LogType.Log,
TAG, ex.Message);
636 Debug.unityLogger.Log(LogType.Log,
TAG,
"Websocket closed with reason: " + reason);
646 if (moduleVersionParts.Length != 3)
670 if (modulePart.Length <= 0)
673 if (modulePart.Length > 2)
681 if (modulePart.Length <= 0)
684 if (modulePart.StartsWith(
"0"))
692 Instance._ExitApplication(nextExitTarget);
697 return Instance._RequestAuthorizationCode();
702 Instance._ChangePlatformServer(newServer);
705 public static void Ping(Action<HttpResponseMessage, object> success =
null, Action<HttpResponseMessage, FailureResponse> failure =
null)
712 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Login with token of token {(string.IsNullOrEmpty(PassedLoginToken) ? "<none>
" : PassedLoginToken)}");
718 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Calling LoginWithToken ({token})");
719 if (token.Length <= 0)
724 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Logging in with token: {token}");
732 Debug.unityLogger.Log(LogType.Log,
TAG,
"_Login called.");
735 Debug.unityLogger.Log(LogType.Log,
TAG,
"API Handler is null.");
738 "There was an error reaching the platform, please contact your administrator."
744 if (login.
Login.Length <= 0)
746 Debug.unityLogger.Log(LogType.Log,
TAG,
"[Login] No user name.");
747 Instance.OnLoginFailed.Invoke(
Instance.GenerateFailureResponse(
"No username or email entered."));
753 Debug.unityLogger.Log(LogType.Log,
TAG,
"[Login] No password.");
754 login.Password =
"<empty>";
759 Debug.unityLogger.Log(LogType.Log,
TAG,
"Login called.");
764 public static bool Login(
string username,
string password)
771 return Instance._CheckModuleAccess(targetModuleID);
774 public static void JoinSession(
string scenarioID =
null,
Extension contextExtension =
null, Action<HttpResponseMessage, JoinSessionResponse> success =
null, Action<HttpResponseMessage, FailureResponse> failure =
null)
779 public static void CompleteSession(
SessionData currentSessionData,
Extension contextExtension =
null,
Extension resultExtension =
null, Action<HttpResponseMessage, object> success =
null, Action<HttpResponseMessage, FailureResponse> failure =
null)
781 Instance._CompleteSession(currentSessionData, contextExtension, resultExtension, success, failure);
784 public static void SendSimpleSessionEvent(
string action,
string targetObject,
Extension contextExtension, Action<HttpResponseMessage, object> success =
null, Action<HttpResponseMessage, FailureResponse> failure =
null)
786 Instance._SendSimpleSessionEvent(action, targetObject, contextExtension, success, failure);
789 public static void SendSessionEvent(Statement eventStatement, Action<HttpResponseMessage, object> success =
null, Action<HttpResponseMessage, FailureResponse> failure =
null)
791 Instance._SendSessionEvent(eventStatement, success, failure);
799 public static bool GetUser(
int userId = -1)
811 return Instance._GetUserModules(userId);
816 return Instance._GetModuleList(platformName);
821 return Instance._GetQuickIDAuthUsers(serialNumber);
824 public static bool QuickIDLogin(
string serialNumber,
string username)
826 return Instance._QuickIDLogin(serialNumber, username);
838 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Calling LoginWithToken ({token})");
839 if (token.Length <= 0)
844 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Logging in with token: {token}");
859 return failureResponse;
864 Debug.unityLogger.Log(LogType.Log,
TAG,
"Parsing passed data.");
865 if (arguments ==
null)
867 Debug.unityLogger.Log(LogType.Log,
TAG,
"No arguments found for the application.");
871 if (arguments.ContainsKey(
"optional"))
874 if (arguments.ContainsKey(
"returntarget"))
877 if (arguments.ContainsKey(
"targettype"))
880 Debug.unityLogger.Log(LogType.Log,
TAG,
"Is the token already set?");
883 Debug.unityLogger.Log(LogType.Log,
TAG,
"Token is not set, but does the arguments contain a token?");
884 if (arguments.ContainsKey(
"pixotoken"))
886 Debug.unityLogger.Log(LogType.Log,
TAG,
"Token was found in the arguments.");
887 string token = arguments[
"pixotoken"];
888 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Found pixotoken {token}.");
889 if (!
string.IsNullOrEmpty(token))
899 Debug.unityLogger.Log(LogType.Log,
TAG,
"_CheckModuleAccess called.");
903 Debug.unityLogger.Log(LogType.Error,
TAG,
"Cannot check user's module access with no active login.");
907 if (targetModuleID <= -1)
912 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Checking module access of module {targetModuleID} from user {currentActiveLogin.ID} and device serial number {(string.IsNullOrEmpty(deviceSerialNumber) == true ? "---
" : deviceSerialNumber)}");
918 protected void _JoinSession(
string newScenarioID,
Extension contextExtension, Action<HttpResponseMessage, JoinSessionResponse> success, Action<HttpResponseMessage, FailureResponse> failure)
922 Debug.unityLogger.Log(LogType.Error,
TAG,
"Cannot join session with no active login.");
923 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"Cannot join session with no active login." });
929 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"User access not verified." });
933 if (newScenarioID !=
null)
940 Debug.unityLogger.Log(LogType.Error,
TAG,
941 "Session is already in progress."
942 +
" The previous session didn't complete or a new session was started during an active session."
948 Statement sessionStatement =
new Statement();
949 Agent sessionActor =
new Agent();
952 Verb sessionVerb =
new Verb();
954 sessionVerb.display =
new LanguageMap();
955 sessionVerb.display.Add(
"en",
"Joined Session");
957 Activity sessionActivity =
new Activity();
958 sessionActivity.id =
string.Format(
"https://pixovr.com/xapi/objects/{0}/{1}",
moduleID,
scenarioID);
960 Context sessionContext =
new Context();
967 sessionStatement.actor = sessionActor;
968 sessionStatement.verb = sessionVerb;
969 sessionStatement.target = sessionActivity;
970 sessionStatement.context = sessionContext;
978 sessionData.JsonData = sessionStatement;
983 protected void _SendSimpleSessionEvent(
string verbName,
string targetObject,
Extension contextExtension, Action<HttpResponseMessage, object> success, Action<HttpResponseMessage, FailureResponse> failure)
985 if (
string.IsNullOrEmpty(verbName))
987 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"Verb name is invalid." });
991 Statement sessionStatement =
new Statement();
993 Verb sessionVerb =
new Verb();
994 sessionVerb.id =
new Uri(
"https://pixovr.com/xapi/verbs/" + verbName.Replace(
' ',
'_').ToLower());
995 sessionVerb.display =
new LanguageMap();
996 sessionVerb.display.Add(
"en", verbName);
998 Activity sessionActivity =
new Activity();
999 sessionActivity.id =
string.Format(
1000 "https://pixovr.com/xapi/objects/{0}/{1}/{2}",
1003 targetObject.Replace(
' ',
'_').ToLower()
1006 Context sessionContext =
new Context();
1009 sessionContext.platform =
platform;
1013 sessionStatement.actor =
null;
1014 sessionStatement.verb = sessionVerb;
1015 sessionStatement.target = sessionActivity;
1016 sessionStatement.context = sessionContext;
1023 sessionEvent.JsonData = sessionStatement;
1028 protected void _SendSessionEvent(Statement eventStatement, Action<HttpResponseMessage, object> success, Action<HttpResponseMessage, FailureResponse> failure)
1032 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"User access not verified." });
1038 Debug.unityLogger.Log(LogType.Error,
TAG,
"Cannot send a session event with no active login.");
1039 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"Cannot send a session event with no active login." });
1045 Debug.unityLogger.Log(LogType.Error,
TAG,
"No session in progress to send event for.");
1046 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"No session in progress to send event for." });
1050 if (eventStatement ==
null)
1052 Debug.unityLogger.Log(LogType.Error,
TAG,
"No event data to send.");
1053 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"No event data to send." });
1057 if (eventStatement.actor !=
null)
1059 Debug.unityLogger.Log(LogType.Warning,
TAG,
"Actor data should not be filled out.");
1062 if (eventStatement.verb ==
null)
1064 Debug.unityLogger.Log(LogType.Error,
TAG,
"Verb missing from eventStatement.");
1065 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"Verb missing from eventStatement." });
1069 if (eventStatement.verb.id ==
null)
1071 Debug.unityLogger.Log(LogType.Error,
TAG,
"verb.id missing from eventStatement.");
1072 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"verb.id missing from eventStatement." });
1076 if (eventStatement.target ==
null)
1078 Debug.unityLogger.Log(LogType.Error,
TAG,
"Object (target) missing from eventStatement.");
1079 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"Object (target) missing from eventStatement." });
1083 eventStatement.actor =
new Agent();
1086 if (eventStatement.context ==
null)
1088 eventStatement.context =
new Context();
1093 eventStatement.context.platform =
platform;
1102 sessionEvent.JsonData = eventStatement;
1107 protected void _CompleteSession(
SessionData currentSessionData,
Extension contextExtension,
Extension resultExtension, Action<HttpResponseMessage, object> success =
null, Action<HttpResponseMessage, FailureResponse> failure =
null)
1111 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"User access not verified." });
1117 Debug.unityLogger.Log(LogType.Error,
TAG,
"Cannot complete session with no active login.");
1118 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"Cannot complete session with no active login." });
1124 Debug.unityLogger.Log(LogType.Error,
TAG,
"No session in progress to complete.");
1125 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"No session in progress to complete." });
1130 Agent sessionActor =
new Agent();
1134 Verb sessionVerb =
new Verb();
1136 sessionVerb.display =
new LanguageMap();
1137 sessionVerb.display.Add(
"en",
"Completed Session");
1140 Activity sessionActivity =
new Activity();
1141 sessionActivity.id =
string.Format(
"https://pixovr.com/xapi/objects/{0}/{1}",
moduleID,
scenarioID);
1144 Context sessionContext =
new Context();
1147 sessionContext.platform =
platform;
1152 Result sessionResult =
new Result();
1153 sessionResult.completion = currentSessionData.
Complete;
1154 sessionResult.success = currentSessionData.
Success;
1156 sessionResult.score =
new Score();
1157 sessionResult.score.min = currentSessionData.
MinimumScore;
1158 sessionResult.score.max = currentSessionData.
MaximumScore;
1159 sessionResult.score.raw = currentSessionData.
Score;
1162 currentSessionData.
Score,
1165 sessionResult.duration = TimeSpan.FromSeconds(currentSessionData.
Duration);
1166 if (resultExtension !=
null)
1168 sessionResult.extensions =
new Extensions(resultExtension.
ToJObject());
1172 Statement sessionStatement =
new Statement();
1173 sessionStatement.actor = sessionActor;
1174 sessionStatement.verb = sessionVerb;
1175 sessionStatement.target = sessionActivity;
1176 sessionStatement.context = sessionContext;
1177 sessionStatement.result = sessionResult;
1184 sessionData.JsonData = sessionStatement;
1185 sessionData.SessionDuration = currentSessionData.
Duration;
1186 sessionData.Score = currentSessionData.
Score;
1187 sessionData.ScoreMin = currentSessionData.
MinimumScore;
1188 sessionData.ScoreMax = currentSessionData.
MaximumScore;
1191 currentSessionData.
Score,
1200 Debug.unityLogger.Log(LogType.Log,
TAG,
"Sending heartbeat...");
1212 protected bool _GetUser(
int userId = -1)
1251 if (String.IsNullOrEmpty(serialNumber))
return false;
1257 protected bool _QuickIDLogin(
string serialNumber,
string username)
1259 if (String.IsNullOrEmpty(serialNumber) ||
string.IsNullOrEmpty(username))
return false;
1267 float determinedScaledScore = scaledScore;
1269 if (scaledScore < Mathf.Epsilon && score >= Mathf.Epsilon)
1271 determinedScaledScore = (score / maxScore) * 100f;
1274 return determinedScaledScore;
1285 if (currentContextExtension !=
null)
1287 contextExtension = currentContextExtension;
1304 return new Extensions(contextExtension.
ToJObject());
1309 Debug.unityLogger.Log(LogType.Log,
TAG,
"On API Response");
1310 bool success = message.IsSuccessStatusCode;
1320 Debug.unityLogger.Log(LogType.Log,
TAG,
"Calling to handle login.");
1333 Debug.unityLogger.Log(LogType.Log,
TAG,
string.Format(
"Failed to get user.\nError: {0}", failureData.
Message));
1347 Debug.unityLogger.Log(LogType.Log,
TAG,
string.Format(
"Failed to get user.\nError: {0}", failureData.
Message));
1357 if (userAccessResponseContent.Access)
1359 if (userAccessResponseContent.PassingScore.HasValue)
1361 currentActiveLogin.MinimumPassingScore = userAccessResponseContent.
PassingScore.Value;
1376 Message =
"User does not have access to module",
1384 Debug.unityLogger.Log(LogType.Log,
TAG,
1386 "Failed to get users module access data.\nError: {0}",
1404 Debug.unityLogger.Log(LogType.Log,
TAG,
1405 string.Format(
"Failed to get org modules.\nError: {0}", failureData.
Message)
1422 Debug.unityLogger.Log(LogType.Log,
TAG,
string.Format(
"Failed to get Quick ID Authentication users.\nError: {0}", failureData.
Message));
1438 Debug.unityLogger.Log(LogType.Log,
TAG,
string.Format(
"Failed to authenticate with Quick ID Authentication.\nError: {0}", failureData.
Message));
1455 protected void HandleLogin(
bool successful,
object responseData)
1457 Debug.unityLogger.Log(LogType.Log,
TAG,
"Handling Login");
1474 Debug.unityLogger.Log(LogType.Log,
TAG,
string.Format(
"Failed to log in.\nError: {0}", failureData.
Message));
1492 Debug.unityLogger.Log(LogType.Error,
TAG,
"No user logged in to generate code.");
1493 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"No user logged in to generate code." });
1501 public static void GenerateOneTimeLoginForUser(
int userId, Action<HttpResponseMessage, object> success, Action<HttpResponseMessage, FailureResponse> failure)
1505 Debug.unityLogger.Log(LogType.Error,
TAG,
"No current user logged in.");
1506 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"No current user logged in." });
1512 Debug.unityLogger.Log(LogType.Error,
TAG,
"User id is invalid.");
1513 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"User id is invalid." });
1524 Debug.LogError(
"[ApexSystem] No user logged in to get the user metrics for the current user org.");
1525 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"No user logged in to retrieve org devices." });
1532 public static void GetDevicesForOrg(
int page,
FilterParams filterParams, Action<HttpResponseMessage, OrgDevicesResponse> success, Action<HttpResponseMessage, FailureResponse> failure)
1536 Debug.LogError(
"[ApexSystem] No user logged in to retrieve org devices.");
1537 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"No user logged in to retrieve org devices." });
1544 public static void GetSesssionHistory(
int page,
SessionFilters sessionFilters,
FilterParams filterParams, Action<HttpResponseMessage, SessionHistoryResponse> success, Action<HttpResponseMessage, FailureResponse> failure)
1548 Debug.LogError(
"[ApexSystem] No user logged in to retrieve session history.");
1549 failure?.Invoke(
null,
new FailureResponse { Error =
"true", Message =
"No user logged in to retrieve session history." });
async void GetUserModules(string authToken, int userId)
async void QuickIDLogin(QuickIDLoginData login)
async void CompleteSession(string authToken, CompleteSessionData completionData, Action< HttpResponseMessage, object > success, Action< HttpResponseMessage, FailureResponse > failure)
async void LoginWithToken(string token)
void SetPlatformEndpoint(string endpointUrl)
async void GetQuickIDAuthenticationUsers(string serialNumber)
async void GetUserData(string authToken, int userId)
async void SendHeartbeat(string authToken, int sessionId, Action< HttpResponseMessage, object > success=null, Action< HttpResponseMessage, FailureResponse > failure=null)
async void SendSessionEvent(string authToken, SessionEventData sessionEvent, Action< HttpResponseMessage, object > success, Action< HttpResponseMessage, FailureResponse > failure)
async void JoinSession(string authToken, JoinSessionData joinData, Action< HttpResponseMessage, JoinSessionResponse > success, Action< HttpResponseMessage, FailureResponse > failure)
async void GetModuleAccess(int moduleId, int userId, string serialNumber)
async void GetModuleList(string authToken, string platform)
const string PIXOVR_SESSION_COMPLETE
const string PIXOVR_SESSION_EVENT
const string PIXOVR_SESSION_JOINED
static readonly string MODULE_ID
bool InitializeInstance(T targetInstance)
Extensions AppendStandardContextExtension(Extensions currentContextExtensions)
OnGeneratedAssistedLoginSuccessEvent OnGeneratedAssistedLoginSuccess
bool runSetupOnAwake
[SerializeField]
static string CurrentExitTarget
static string PassedLoginToken
Task socketDisconnectTask
static bool LoginCheckModuleAccess
void _CompleteSession(SessionData currentSessionData, Extension contextExtension, Extension resultExtension, Action< HttpResponseMessage, object > success=null, Action< HttpResponseMessage, FailureResponse > failure=null)
static bool QuickIDLogin(string serialNumber, string username)
static bool GetCurrentUser()
static bool GenerateOneTimeLoginForCurrentUser(Action< HttpResponseMessage, object > success, Action< HttpResponseMessage, FailureResponse > failure)
static bool RunSetupOnAwake
static void SendSessionEvent(Statement eventStatement, Action< HttpResponseMessage, object > success=null, Action< HttpResponseMessage, FailureResponse > failure=null)
FailureResponse GenerateFailureResponse(string message)
string GetPlatformEndpointFromPlatformTarget(PlatformServer target)
void _ChangePlatformServer(PlatformServer newServer)
int moduleID
[SerializeField]
static bool Login(string username, string password)
string deviceSerialNumber
OnApexFailureEvent OnGeneratedAssistedLoginFailed
static void SendSimpleSessionEvent(string action, string targetObject, Extension contextExtension, Action< HttpResponseMessage, object > success=null, Action< HttpResponseMessage, FailureResponse > failure=null)
static string APIEndpoint
string targetTypeParameter
static void Ping(Action< HttpResponseMessage, object > success=null, Action< HttpResponseMessage, FailureResponse > failure=null)
OnGetQuickIDAuthUsersSuccessEvent OnGetQuickIDAuthGetUsersSuccess
void OnAPIResponse(ResponseType response, HttpResponseMessage message, object responseData)
static void ExitApplication(string nextExitTarget="")
OnApexFailureEvent OnGetUserFailed
OnAuthCodeReceived OnAuthorizationCodeReceived
OnGetOrgModulesSuccessEvent OnGetOrganizationModulesSuccess
static bool RequestAuthorizationCode()
void SetupPlatformConfiguration()
PlatformResponse OnPlatformResponse
static bool GetUser(int userId=-1)
static bool GetQuickIDAuthUsers(string serialNumber)
string moduleVersion
[SerializeField]
string GetEndpointFromTarget(PlatformServer target)
OnLoginSuccessEvent OnLoginSuccess
void OnWebSocketConnectFailed(string reason)
static bool CheckModuleAccess(int targetModuleID=-1)
OnQuickIDAuthLoginSuccessEvent OnQuickIDAuthLoginSuccess
void OnWebSocketReceive(string data)
bool _RequestAuthorizationCode()
void PopulateWebSocketURL()
void HandleLogin(bool successful, object responseData)
void DisconnectWebsocket()
static void GenerateOneTimeLoginForUser(int userId, Action< HttpResponseMessage, object > success, Action< HttpResponseMessage, FailureResponse > failure)
static bool GetUserModules(int userId=-1)
void _SendSimpleSessionEvent(string verbName, string targetObject, Extension contextExtension, Action< HttpResponseMessage, object > success, Action< HttpResponseMessage, FailureResponse > failure)
static LoginResponseContent CurrentActiveLogin
bool _GetQuickIDAuthUsers(string serialNumber)
string currentExitTargetParameter
static APIHandler ApexAPIHandler
static void GetSesssionHistory(int page, SessionFilters sessionFilters, FilterParams filterParams, Action< HttpResponseMessage, SessionHistoryResponse > success, Action< HttpResponseMessage, FailureResponse > failure)
float DetermineScaledScore(float scaledScore, float score, float maxScore)
APIHandler apexAPIHandler
static bool GetCurrentUserModules()
static bool GetModulesList(string platformName)
static void CompleteSession(SessionData currentSessionData, Extension contextExtension=null, Extension resultExtension=null, Action< HttpResponseMessage, object > success=null, Action< HttpResponseMessage, FailureResponse > failure=null)
Task< bool > socketConnectTask
static void GetUserMetricsForCurrentUsersOrg(int page, FilterParams filterParams, Action< UserMetricsResponse, object > success, Action< HttpResponseMessage, FailureResponse > failure)
OnApexFailureEvent OnGetQuickIDAuthGetUsersFailed
static void ChangePlatformServer(PlatformServer newServer)
static string ModuleVersion
static bool LoginWithToken()
bool loginCheckModuleAccess
[SerializeField]
OnApexFailureEvent OnGetUserModulesFailed
OnApexFailureEvent OnLoginFailed
static bool Login(LoginData login)
bool IsModuleVersionValid()
void _ParsePassedData(Dictionary< string, string > arguments)
static void JoinSession(string scenarioID=null, Extension contextExtension=null, Action< HttpResponseMessage, JoinSessionResponse > success=null, Action< HttpResponseMessage, FailureResponse > failure=null)
static string DeviceSerialNumber
void _SendSessionEvent(Statement eventStatement, Action< HttpResponseMessage, object > success, Action< HttpResponseMessage, FailureResponse > failure)
LoginResponseContent currentActiveLogin
bool _LoginWithToken(string token)
static readonly Regex VersionValidator
void _JoinSession(string newScenarioID, Extension contextExtension, Action< HttpResponseMessage, JoinSessionResponse > success, Action< HttpResponseMessage, FailureResponse > failure)
OnApexFailureEvent OnGetOrganizationModulesFailed
float heartbeatTime
[SerializeField]
OnApexFailureEvent OnModuleAccessFailed
OnApexFailureEvent OnQuickIDAuthLoginFailed
static string OptionalData
string scenarioID
[SerializeField]
static readonly string TAG
OnModuleAccessSuccessEvent OnModuleAccessSuccess
void _ExitApplication(string nextExitApplication)
bool _GetUser(int userId=-1)
OnGetUserSuccessEvent OnGetUserSuccess
bool _QuickIDLogin(string serialNumber, string username)
bool _CheckModuleAccess(int targetModuleID=-1)
bool IsModuleVersionOnlyNumerical()
string serverIP
[SerializeField]
void OnWebSocketClosed(System.Net.WebSockets.WebSocketCloseStatus reason)
static void GetDevicesForOrg(int page, FilterParams filterParams, Action< HttpResponseMessage, OrgDevicesResponse > success, Action< HttpResponseMessage, FailureResponse > failure)
bool _GetModuleList(string platformName)
static bool LoginWithToken(string token)
PlatformServer PlatformTargetServer
OnGetUserModulesSuccessEvent OnGetUserModulesSuccess
Extensions AppendStandardContextExtension(Extension currentContextExtension)
void OnWebSocketConnected()
string moduleName
[SerializeField]
bool IsModuleNonMajorVersionPartValid(string modulePart)
bool _GetUserModules(int userId=-1)
bool IsModuleMajorVersionPartValid(string modulePart)
void OnDeepLinkActivated(string url)
static readonly Uri JOINED_SESSION
static readonly Uri COMPLETED_SESSION
bool RequestAuthorizationCode()
async Task< bool > Connect(Uri endpoint, int attemptTries=3)
OnWebSocketReceive OnReceive
OnWebSocketConnectFailed OnConnectFailed
OnWebSocketClosed OnClosed
OnWebSocketConnectSuccessful OnConnectSuccess
static bool DoesFileExistInSharedLocation(string fileName)
static string ReadFileFromSharedStorage(string fileName)
static string GetMacAddress()
void Add(Uri key, string value)
void AddSimple(string key, string value)
override JObject ToJObject(TCAPIVersion version)
delegate void PlatformResponse(ResponseType type, bool wasSuccessful, object responseData)