2using System.Collections.Generic;
4using System.Text.RegularExpressions;
5using System.Threading.Tasks;
22 [DefaultExecutionOrder(-50)]
25 private static readonly
string TAG =
"ApexSystem";
42 set { Instance.moduleID = value; }
48 set { Instance.moduleName = value; }
53 get {
return Instance.moduleVersion; }
54 set { Instance.moduleVersion = value; }
60 set { Instance.scenarioID = value; }
65 get {
return Instance.currentActiveLogin; }
71 get {
return Instance.runSetupOnAwake; }
72 set { Instance.runSetupOnAwake = value; }
77 get {
return Instance.loginCheckModuleAccess; }
83 get {
return Instance.deviceSerialNumber; }
91 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Getting passed login token as {Instance.loginToken} in instance {Instance.gameObject.name}");
97 Debug.unityLogger.Log(LogType.Error,
TAG, $
"Setting passed login token to {value}");
98 Instance.loginToken = value;
104 get {
return Instance.optionalParameter; }
105 set { Instance.optionalParameter = value; }
110 get {
return Instance.currentExitTargetParameter; }
115 Instance.currentExitTargetParameter = value;
119 Instance.currentExitTargetParameter =
"";
122 if (
Instance.currentExitTargetParameter.Contains(
"://"))
135 get {
return Instance.targetTypeParameter; }
136 private set { Instance.targetTypeParameter = value; }
139 [SerializeField, EndpointDisplay]
235 Debug.unityLogger.Log(LogType.Log,
TAG, $
"ApexSystem found on {gameObject.name}");
238 Debug.unityLogger.Log(LogType.Log,
TAG,
"Instance already initialized.");
243#if UNITY_IOS || UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
248 Debug.unityLogger.Log(LogType.Log,
TAG,
"Running on awake!");
252 DontDestroyOnLoad(gameObject);
253#if MANAGE_XR && !UNITY_EDITOR
254 Debug.unityLogger.Log(LogType.Log,
TAG,
"Using ManageXR");
260 async
void InitMXRSDK()
262 Debug.unityLogger.Log(LogType.Log,
TAG,
"Initializing the ManageXR SDK");
263 await MXRManager.InitAsync();
264 MXRManager.System.OnDeviceStatusChange += OnDeviceStatusChanged;
266 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Device serial set to {deviceSerialNumber}");
269 void OnDeviceStatusChanged(DeviceStatus newDeviceStatus)
272 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Device serial number changed to {deviceSerialNumber}");
279 if (!
string.IsNullOrEmpty(Application.absoluteURL))
295 Debug.unityLogger.Log(LogType.Log,
TAG,
"SetupPlatformConfiguration");
300 Debug.unityLogger.Log(LogType.Log,
TAG,
"Found pixoconfig.cnf");
304 if (configContent.Length > 0)
306 Debug.unityLogger.Log(LogType.Log,
TAG,
"Configuration is not empty.");
308 if (configData ==
null)
310 Debug.unityLogger.Log(LogType.Log,
TAG,
"Failed to deserialize the config.");
315 if (configData.
Platform.Contains(
"NA", StringComparison.CurrentCultureIgnoreCase))
317 if (configData.
Platform.Contains(
"Production", StringComparison.CurrentCultureIgnoreCase))
319 Debug.unityLogger.Log(LogType.Log,
TAG,
"NA Production platform target.");
323 if (configData.
Platform.Contains(
"Dev", StringComparison.CurrentCultureIgnoreCase))
325 Debug.unityLogger.Log(LogType.Log,
TAG,
"NA Dev platform target.");
329 if (configData.
Platform.Contains(
"Stage", StringComparison.CurrentCultureIgnoreCase))
331 Debug.unityLogger.Log(LogType.Log,
TAG,
"NA Stage platform target.");
335 else if (configData.
Platform.Contains(
"SA", StringComparison.CurrentCultureIgnoreCase))
337 Debug.unityLogger.Log(LogType.Log,
TAG,
"SA Production platform target.");
360 Debug.unityLogger.Log(LogType.Log,
TAG,
"Apex API Handler is not null!");
387 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Login Token: {(string.IsNullOrEmpty(PassedLoginToken) ? "<Null>
" : PassedLoginToken)}");
394 Debug.unityLogger.Log(LogType.Log,
TAG,
"ApexSystem::_ExitApplication");
395 if (nextExitApplication ==
null)
397 nextExitApplication =
"";
400 string returnTargetType =
"app";
402 if (nextExitApplication.Contains(
"://"))
404 returnTargetType =
"url";
407 Debug.unityLogger.Log(LogType.Log,
TAG,
"" + nextExitApplication +
" " + returnTargetType);
409 string parameters =
"";
411 Debug.unityLogger.Log(LogType.Log,
TAG,
"Building parameters for url.");
426 if (parameters.Length > 0)
432 if (nextExitApplication.Length > 0)
434 if (parameters.Length > 0)
436 parameters +=
"returntarget=" + nextExitApplication;
439 if (returnTargetType.Length > 0)
441 if (parameters.Length > 0)
443 parameters +=
"targettype=" + returnTargetType;
446 Debug.unityLogger.Log(LogType.Log,
TAG,
"Checking the return target parameter.");
450 Debug.unityLogger.Log(LogType.Log,
TAG,
"Had a valid return target parameter.");
453 Debug.unityLogger.Log(LogType.Log,
TAG,
"Return Target is a URL.");
456 if (!
string.IsNullOrEmpty(parameters))
458 if (!returnURL.Contains(
'?'))
463 returnURL += parameters;
465 Debug.unityLogger.Log(LogType.Log,
TAG,
"Custom Target: " + returnURL);
471 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Return Target is a package name. {CurrentExitTarget}");
473 List<string> keys =
new List<string>(),
474 values =
new List<string>();
476 Debug.unityLogger.Log(LogType.Log,
TAG,
"Adding pixo token.");
480 keys.Add(
"pixotoken");
485 keys.Add(
"pixotoken");
489 Debug.unityLogger.Log(LogType.Log,
TAG,
"Adding optional.");
493 keys.Add(
"optional");
497 Debug.unityLogger.Log(LogType.Log,
TAG,
"Adding return target.");
499 if (!
string.IsNullOrEmpty(nextExitApplication))
501 keys.Add(
"returntarget");
502 values.Add(nextExitApplication);
505 Debug.unityLogger.Log(LogType.Log,
TAG,
"Adding return target type.");
507 if (!
string.IsNullOrEmpty(returnTargetType))
509 keys.Add(
"targettype");
510 values.Add(returnTargetType);
523 return target.ToUrlString();
528 int targetValue = (int)target;
531 return webTarget.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();
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()
712 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Login with token of token {(string.IsNullOrEmpty(PassedLoginToken) ? "<none>
" : PassedLoginToken)}");
718 return Instance._LoginWithToken(token);
726 public static bool Login(
string username,
string password)
728 return Instance._Login(username, password);
733 return Instance._CheckModuleAccess(targetModuleID);
747 return Instance._CompleteSession(currentSessionData, contextExtension, resultExtension);
752 return Instance._SendSimpleSessionEvent(action, targetObject, contextExtension);
757 return Instance._SendSessionEvent(eventStatement);
765 public static bool GetUser(
int userId = -1)
777 return Instance._GetUserModules(userId);
782 return Instance._GetModuleList(platformName);
787 return Instance._GetQuickIDAuthUsers(serialNumber);
790 public static bool QuickIDLogin(
string serialNumber,
string username)
792 return Instance._QuickIDLogin(serialNumber, username);
802 protected void _Ping()
809 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Calling LoginWithToken ({token})");
810 if (token.Length <= 0)
815 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Logging in with token: {token}");
823 Debug.unityLogger.Log(LogType.Log,
TAG,
"_Login called.");
826 Debug.unityLogger.Log(LogType.Log,
TAG,
"API Handler is null.");
829 "There was an error reaching the platform, please contact your administrator."
835 if (login.
Login.Length <= 0)
837 Debug.unityLogger.Log(LogType.Log,
TAG,
"[Login] No user name.");
844 Debug.unityLogger.Log(LogType.Log,
TAG,
"[Login] No password.");
845 login.Password =
"<empty>";
850 Debug.unityLogger.Log(LogType.Log,
TAG,
"Login called.");
855 protected bool _Login(
string username,
string password)
863 failureResponse.Error =
"true";
864 failureResponse.HttpCode =
"400";
865 failureResponse.Message = message;
867 return failureResponse;
872 Debug.unityLogger.Log(LogType.Log,
TAG,
"Parsing passed data.");
873 if (arguments ==
null)
875 Debug.unityLogger.Log(LogType.Log,
TAG,
"No arguments found for the application.");
879 if (arguments.ContainsKey(
"optional"))
882 if (arguments.ContainsKey(
"returntarget"))
885 if (arguments.ContainsKey(
"targettype"))
888 Debug.unityLogger.Log(LogType.Log,
TAG,
"Is the token already set?");
891 Debug.unityLogger.Log(LogType.Log,
TAG,
"Token is not set, but does the arguments contain a token?");
892 if (arguments.ContainsKey(
"pixotoken"))
894 Debug.unityLogger.Log(LogType.Log,
TAG,
"Token was found in the arguments.");
895 string token = arguments[
"pixotoken"];
896 Debug.unityLogger.Log(LogType.Log,
TAG, $
"Found pixotoken {token}.");
897 if (!
string.IsNullOrEmpty(token))
907 Debug.unityLogger.Log(LogType.Log,
TAG,
"_CheckModuleAccess called.");
911 Debug.unityLogger.Log(LogType.Error,
TAG,
"Cannot check user's module access with no active login.");
915 if (targetModuleID <= -1)
920 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)}");
930 Debug.unityLogger.Log(LogType.Error,
TAG,
"Cannot join session with no active login.");
939 if (newScenarioID !=
null)
946 Debug.unityLogger.Log(LogType.Error,
TAG,
947 "Session is already in progress."
948 +
" The previous session didn't complete or a new session was started during an active session."
954 Statement sessionStatement =
new Statement();
955 Agent sessionActor =
new Agent();
958 Verb sessionVerb =
new Verb();
960 sessionVerb.display =
new LanguageMap();
961 sessionVerb.display.Add(
"en",
"Joined Session");
963 Activity sessionActivity =
new Activity();
964 sessionActivity.id =
string.Format(
"https://pixovr.com/xapi/objects/{0}/{1}",
moduleID,
scenarioID);
966 Context sessionContext =
new Context();
973 sessionStatement.actor = sessionActor;
974 sessionStatement.verb = sessionVerb;
975 sessionStatement.target = sessionActivity;
976 sessionStatement.context = sessionContext;
984 sessionData.JsonData = sessionStatement;
996 if (verbName ==
null)
999 if (verbName.Length == 0)
1002 Statement sessionStatement =
new Statement();
1003 Agent sessionActor =
new Agent();
1006 Verb sessionVerb =
new Verb();
1007 sessionVerb.id =
new Uri(
"https://pixovr.com/xapi/verbs/" + verbName.Replace(
' ',
'_').ToLower());
1008 sessionVerb.display =
new LanguageMap();
1009 sessionVerb.display.Add(
"en", verbName);
1011 Activity sessionActivity =
new Activity();
1012 sessionActivity.id =
string.Format(
1013 "https://pixovr.com/xapi/objects/{0}/{1}/{2}",
1016 targetObject.Replace(
' ',
'_').ToLower()
1019 Context sessionContext =
new Context();
1022 sessionContext.platform =
platform;
1026 sessionStatement.actor = sessionActor;
1027 sessionStatement.verb = sessionVerb;
1028 sessionStatement.target = sessionActivity;
1029 sessionStatement.context = sessionContext;
1036 sessionEvent.JsonData = sessionStatement;
1052 Debug.unityLogger.Log(LogType.Error,
TAG,
"Cannot send a session event with no active login.");
1058 Debug.unityLogger.Log(LogType.Error,
TAG,
"No session in progress to send event for.");
1062 if (eventStatement ==
null)
1064 Debug.unityLogger.Log(LogType.Error,
TAG,
"No event data to send.");
1068 if (eventStatement.actor !=
null)
1070 Debug.unityLogger.Log(LogType.Warning,
TAG,
"Actor data should not be filled out.");
1073 if (eventStatement.verb ==
null)
1075 Debug.unityLogger.Log(LogType.Error,
TAG,
"Verb missing from eventStatement.");
1079 if (eventStatement.verb.id ==
null)
1081 Debug.unityLogger.Log(LogType.Error,
TAG,
"verb.id missing from eventStatement.");
1085 if (eventStatement.target ==
null)
1087 Debug.unityLogger.Log(LogType.Error,
TAG,
"Object (target) missing from eventStatement.");
1091 eventStatement.actor =
new Agent();
1094 if (eventStatement.context ==
null)
1096 eventStatement.context =
new Context();
1101 eventStatement.context.platform =
platform;
1110 sessionEvent.JsonData = eventStatement;
1130 Debug.unityLogger.Log(LogType.Error,
TAG,
"Cannot complete session with no active login.");
1136 Debug.unityLogger.Log(LogType.Error,
TAG,
"No session in progress to complete.");
1141 Agent sessionActor =
new Agent();
1145 Verb sessionVerb =
new Verb();
1147 sessionVerb.display =
new LanguageMap();
1148 sessionVerb.display.Add(
"en",
"Completed Session");
1151 Activity sessionActivity =
new Activity();
1152 sessionActivity.id =
string.Format(
"https://pixovr.com/xapi/objects/{0}/{1}",
moduleID,
scenarioID);
1155 Context sessionContext =
new Context();
1158 sessionContext.platform =
platform;
1163 Result sessionResult =
new Result();
1164 sessionResult.completion = currentSessionData.
Complete;
1165 sessionResult.success = currentSessionData.
Success;
1167 sessionResult.score =
new Score();
1168 sessionResult.score.min = currentSessionData.
MinimumScore;
1169 sessionResult.score.max = currentSessionData.
MaximumScore;
1170 sessionResult.score.raw = currentSessionData.
Score;
1173 currentSessionData.
Score,
1176 sessionResult.duration = TimeSpan.FromSeconds(currentSessionData.
Duration);
1177 if (resultExtension !=
null)
1179 sessionResult.extensions =
new Extensions(resultExtension.
ToJObject());
1183 Statement sessionStatement =
new Statement();
1184 sessionStatement.actor = sessionActor;
1185 sessionStatement.verb = sessionVerb;
1186 sessionStatement.target = sessionActivity;
1187 sessionStatement.context = sessionContext;
1188 sessionStatement.result = sessionResult;
1195 sessionData.JsonData = sessionStatement;
1196 sessionData.SessionDuration = currentSessionData.
Duration;
1197 sessionData.Score = currentSessionData.
Score;
1198 sessionData.ScoreMin = currentSessionData.
MinimumScore;
1199 sessionData.ScoreMax = currentSessionData.
MaximumScore;
1202 currentSessionData.
Score,
1213 Debug.unityLogger.Log(LogType.Log,
TAG,
"Sending heartbeat...");
1225 protected bool _GetUser(
int userId = -1)
1264 if (String.IsNullOrEmpty(serialNumber))
return false;
1270 protected bool _QuickIDLogin(
string serialNumber,
string username)
1272 if (String.IsNullOrEmpty(serialNumber) ||
string.IsNullOrEmpty(username))
return false;
1280 float determinedScaledScore = scaledScore;
1282 if (scaledScore < Mathf.Epsilon && score >= Mathf.Epsilon)
1284 determinedScaledScore = (score / maxScore) * 100f;
1287 return determinedScaledScore;
1298 if (currentContextExtension !=
null)
1300 contextExtension = currentContextExtension;
1317 return new Extensions(contextExtension.
ToJObject());
1322 Debug.unityLogger.Log(LogType.Log,
TAG,
"On API Response");
1323 bool success = message.IsSuccessStatusCode;
1335 Debug.unityLogger.Log(LogType.Log,
TAG,
"Ping successful.");
1340 Debug.unityLogger.Log(LogType.Log,
TAG,
"Ping failed.");
1347 Debug.unityLogger.Log(LogType.Log,
TAG,
"Calling to handle login.");
1360 Debug.unityLogger.Log(LogType.Log,
TAG,
string.Format(
"Failed to get user.\nError: {0}", failureData.
Message));
1374 Debug.unityLogger.Log(LogType.Log,
TAG,
string.Format(
"Failed to get user.\nError: {0}", failureData.
Message));
1384 Debug.unityLogger.Log(LogType.Log,
TAG,
string.Format(
"Session Id is {0}.", joinSessionResponse.
SessionId));
1392 Debug.unityLogger.Log(LogType.Log,
TAG,
1393 string.Format(
"Failed to join session.\nError: {0}", failureData.
Message)
1412 Debug.unityLogger.Log(LogType.Log,
TAG,
1413 string.Format(
"Failed to complete session.\nError: {0}", failureData.
Message)
1423 Debug.unityLogger.Log(LogType.Log,
TAG,
"Session event sent.");
1429 Debug.unityLogger.Log(LogType.Log,
TAG,
1430 string.Format(
"Failed to send session event.\nError: {0}", failureData.
Message)
1441 if (userAccessResponseContent.Access)
1443 if (userAccessResponseContent.PassingScore.HasValue)
1445 currentActiveLogin.MinimumPassingScore = userAccessResponseContent.
PassingScore.Value;
1460 Message =
"User does not have access to module",
1468 Debug.unityLogger.Log(LogType.Log,
TAG,
1470 "Failed to get users module access data.\nError: {0}",
1488 Debug.unityLogger.Log(LogType.Log,
TAG,
1489 string.Format(
"Failed to get org modules.\nError: {0}", failureData.
Message)
1506 Debug.unityLogger.Log(LogType.Log,
TAG,
string.Format(
"Failed to get Quick ID Authentication users.\nError: {0}", failureData.
Message));
1522 Debug.unityLogger.Log(LogType.Log,
TAG,
string.Format(
"Failed to authenticate with Quick ID Authentication.\nError: {0}", failureData.
Message));
1537 string.Format(
"[ApexSystem] Failed to get user metrics for org.\nError: {0}", failureData.
Message)
1555 protected void HandleLogin(
bool successful,
object responseData)
1557 Debug.unityLogger.Log(LogType.Log,
TAG,
"Handling Login");
1574 Debug.unityLogger.Log(LogType.Log,
TAG,
string.Format(
"Failed to log in.\nError: {0}", failureData.
Message));
1590 return Instance._GenerateOneTimeLoginForCurrentUser(success, failure);
1593 public static bool GenerateOneTimeLoginForUser(
int userId, Action<HttpResponseMessage, object> success, Action<HttpResponseMessage, FailureResponse> failure)
1595 return Instance._GenerateOneTimeLoginForUser(userId, success, failure);
1600 if (
Instance.currentActiveLogin ==
null )
1602 return Instance._GetUserMetricsForCurrentUsersOrg(page);
1605 bool _GenerateOneTimeLoginForUser(
int userId, Action<HttpResponseMessage, object> success, Action<HttpResponseMessage, FailureResponse> failure)
1609 Debug.unityLogger.Log(LogType.Error,
TAG,
"No current user logged in.");
1615 Debug.unityLogger.Log(LogType.Error,
TAG,
"User id is invalid.");
1627 Debug.unityLogger.Log(LogType.Error,
TAG,
"No user logged in to generate code.");
1639 Debug.LogError(
"[ApexSystem] No user logged in to retrieve users.");
async void SendHeartbeat(string authToken, int sessionId)
async void GetUserModules(string authToken, int userId)
async void QuickIDLogin(QuickIDLoginData login)
async void JoinSession(string authToken, JoinSessionData joinData)
async void GetUserMetricsForOrg(string authToken, int orgID, int page)
async void LoginWithToken(string token)
async void CompleteSession(string authToken, CompleteSessionData completionData)
async void Login(LoginData login)
async void SendSessionEvent(string authToken, SessionEventData sessionEvent)
void SetPlatformEndpoint(string endpointUrl)
async void GenerateAssistedLogin(string authToken, int userId, Action< HttpResponseMessage, object > success, Action< HttpResponseMessage, FailureResponse > failure)
async void GetQuickIDAuthenticationUsers(string serialNumber)
async void GetUserData(string authToken, int userId)
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)
bool _GenerateOneTimeLoginForUser(int userId, Action< HttpResponseMessage, object > success, Action< HttpResponseMessage, FailureResponse > failure)
OnHttpResponseEvent OnPingSuccess
Extensions AppendStandardContextExtension(Extensions currentContextExtensions)
OnGeneratedAssistedLoginSuccessEvent OnGeneratedAssistedLoginSuccess
bool runSetupOnAwake
[SerializeField]
static string CurrentExitTarget
static string PassedLoginToken
Task socketDisconnectTask
static bool LoginCheckModuleAccess
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 bool GetUserMetricsForCurrentUsersOrg(int page)
FailureResponse GenerateFailureResponse(string message)
OnApexFailureEvent OnJoinSessionFailed
string GetPlatformEndpointFromPlatformTarget(PlatformServer target)
void _ChangePlatformServer(PlatformServer newServer)
int moduleID
[SerializeField]
static bool Login(string username, string password)
string deviceSerialNumber
bool _GenerateOneTimeLoginForCurrentUser(Action< HttpResponseMessage, object > success, Action< HttpResponseMessage, FailureResponse > failure)
OnApexFailureEvent OnGeneratedAssistedLoginFailed
string targetTypeParameter
OnHttpResponseEvent OnPingFailed
static bool SendSessionEvent(Statement eventStatement)
OnGetQuickIDAuthUsersSuccessEvent OnGetQuickIDAuthGetUsersSuccess
string GetWebEndpointFromPlatformTarget(PlatformServer target)
void OnAPIResponse(ResponseType response, HttpResponseMessage message, object responseData)
static void ExitApplication(string nextExitTarget="")
OnHttpResponseEvent OnJoinSessionSuccess
OnApexFailureEvent OnGetUserFailed
OnAuthCodeReceived OnAuthorizationCodeReceived
OnGetOrgModulesSuccessEvent OnGetOrganizationModulesSuccess
bool _JoinSession(string newScenarioID=null, Extension contextExtension=null)
bool _Login(LoginData login)
static bool RequestAuthorizationCode()
bool _CompleteSession(SessionData currentSessionData, Extension contextExtension, Extension resultExtension)
void SetupPlatformConfiguration()
PlatformResponse OnPlatformResponse
static bool GetUser(int userId=-1)
OnHttpResponseEvent OnCompleteSessionSuccess
static bool GetQuickIDAuthUsers(string serialNumber)
string moduleVersion
[SerializeField]
string GetEndpointFromTarget(PlatformServer target)
bool _SendSimpleSessionEvent(string verbName, string targetObject, Extension contextExtension)
OnApexFailureEvent OnCompleteSessionFailed
OnLoginSuccessEvent OnLoginSuccess
void OnWebSocketConnectFailed(string reason)
static bool CheckModuleAccess(int targetModuleID=-1)
OnApexFailureEvent OnSendEventFailed
OnQuickIDAuthLoginSuccessEvent OnQuickIDAuthLoginSuccess
void OnWebSocketReceive(string data)
bool _RequestAuthorizationCode()
void PopulateWebSocketURL()
void HandleLogin(bool successful, object responseData)
void DisconnectWebsocket()
static bool GetUserModules(int userId=-1)
static LoginResponseContent CurrentActiveLogin
bool _GetQuickIDAuthUsers(string serialNumber)
string currentExitTargetParameter
static bool SendSimpleSessionEvent(string action, string targetObject, Extension contextExtension)
OnGetUserMetricsForOrgSuccessEvent OnGetUserMetricsForOrgSuccess
float DetermineScaledScore(float scaledScore, float score, float maxScore)
APIHandler apexAPIHandler
static bool GetCurrentUserModules()
static bool GetModulesList(string platformName)
Task< bool > socketConnectTask
OnApexFailureEvent OnGetQuickIDAuthGetUsersFailed
static void ChangePlatformServer(PlatformServer newServer)
static string ModuleVersion
static bool LoginWithToken()
bool _Login(string username, string password)
static bool JoinSession(string scenarioID=null, Extension contextExtension=null)
bool loginCheckModuleAccess
[SerializeField]
OnApexFailureEvent OnGetUserModulesFailed
bool _SendSessionEvent(Statement eventStatement)
OnApexFailureEvent OnLoginFailed
static bool Login(LoginData login)
bool IsModuleVersionValid()
void _ParsePassedData(Dictionary< string, string > arguments)
static string DeviceSerialNumber
LoginResponseContent currentActiveLogin
bool _LoginWithToken(string token)
static readonly Regex VersionValidator
OnApexFailureEvent OnGetOrganizationModulesFailed
float heartbeatTime
[SerializeField]
OnApexFailureEvent OnModuleAccessFailed
static bool GenerateOneTimeLoginForUser(int userId, Action< HttpResponseMessage, object > success, Action< HttpResponseMessage, FailureResponse > failure)
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
OnHttpResponseEvent OnSendEventSuccess
bool _QuickIDLogin(string serialNumber, string username)
bool _CheckModuleAccess(int targetModuleID=-1)
static bool CompleteSession(SessionData currentSessionData, Extension contextExtension=null, Extension resultExtension=null)
bool IsModuleVersionOnlyNumerical()
bool _GetUserMetricsForCurrentUsersOrg(int page)
OnApexFailureEvent OnGetUserMetricsForOrgFailed
string serverIP
[SerializeField]
void OnWebSocketClosed(System.Net.WebSockets.WebSocketCloseStatus reason)
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)