Пример #1
0
 private void OnLicenseExpired(object sender, License lic)
 {
     LicenseExpired(this, lic.hardLimitTime); // inform hard limit
 }
Пример #2
0
 private void OnGetLicenseInfoDone(object sender, License lic)
 {
     //LicenseValidTo(this, lic.validTo);
     _headsetFinder.FinderInit();
 }
Пример #3
0
 /// <summary>
 /// Handle response message.
 /// A response means success message to distinguish from error object
 /// </summary>
 private void HandleResponse(string method, JToken data)
 {
     // UnityEngine.Debug.Log("handleResponse: " + method);
     if (method == "queryHeadsets")
     {
         List <Headset> headsetLists = new List <Headset>();
         foreach (JObject item in data)
         {
             headsetLists.Add(new Headset(item));
         }
         QueryHeadsetOK(this, headsetLists);
     }
     else if (method == "controlDevice")
     {
         string command = (string)data["command"];
         if (command == "connect")
         {
             string message = (string)data["message"];
         }
         else if (command == "disconnect")
         {
             HeadsetDisConnectedOK(this, true);
         }
     }
     else if (method == "getUserLogin")
     {
         JArray       users     = (JArray)data;
         UserDataInfo loginData = new UserDataInfo();
         if (users.Count > 0)
         {
             foreach (JObject user in users)
             {
                 if (user["currentOSUId"].ToString() == user["loggedInOSUId"].ToString())
                 {
                     loginData.EmotivId = user["username"].ToString();
                     DateTime lastLoginTime = user.Value <DateTime>("lastLoginTime");
                     loginData.LastLoginTime = Utils.ISODateTimeToEpocTime(lastLoginTime);
                 }
             }
         }
         GetUserLoginDone(this, loginData);
     }
     else if (method == "hasAccessRight")
     {
         bool hasAccessRight = (bool)data["accessGranted"];
         HasAccessRightOK(this, hasAccessRight);
     }
     else if (method == "requestAccess")
     {
         bool hasAccessRight = (bool)data["accessGranted"];
         ORequestAccessDone(this, hasAccessRight);
     }
     else if (method == "generateNewToken")
     {
         string cortexToken = data["cortexToken"].ToString();
         RefreshTokenOK(this, cortexToken);
     }
     else if (method == "getLicenseInfo")
     {
         License lic = new License(data["license"]);
         GetLicenseInfoDone(this, lic);
     }
     else if (method == "getUserInformation")
     {
         //TODO
     }
     else if (method == "authorize")
     {
         string token = (string)data["cortexToken"];
         if (data["warning"] != null)
         {
             JObject warning        = (JObject)data["warning"];
             string  warningMessage = warning["message"].ToString();
             UnityEngine.Debug.Log("User has not accepted eula. Please accept EULA on EMOTIV App to proceed.");
             EULANotAccepted(this, warningMessage);
         }
         AuthorizeOK(this, token);
     }
     else if (method == "createSession")
     {
         string  sessionId = (string)data["id"];
         string  status    = (string)data["status"];
         string  appId     = (string)data["appId"];
         JObject headset   = (JObject)data["headset"];
         string  headsetId = headset["id"].ToString();
         CreateSessionOK(this, new SessionEventArgs(sessionId, status, appId, headsetId));
     }
     else if (method == "updateSession")
     {
         string  sessionId = (string)data["id"];
         string  status    = (string)data["status"];
         string  appId     = (string)data["appId"];
         JObject headset   = (JObject)data["headset"];
         string  headsetId = headset["id"].ToString();
         UpdateSessionOK(this, new SessionEventArgs(sessionId, status, appId, headsetId));
     }
     else if (method == "createRecord")
     {
         Record record = new Record((JObject)data["record"]);
         CreateRecordOK(this, record);
     }
     else if (method == "stopRecord")
     {
         Record record = new Record((JObject)data["record"]);
         StopRecordOK(this, record);
     }
     else if (method == "updateRecord")
     {
         Record record = new Record((JObject)data);
         UpdateRecordOK(this, record);
     }
     else if (method == "queryRecords")
     {
         int           count       = (int)data["count"];
         JArray        records     = (JArray)data["records"];
         List <Record> recordLists = new List <Record>();
         foreach (JObject ele in records)
         {
             recordLists.Add(new Record(ele));
         }
         QueryRecordsDone(this, recordLists);
     }
     else if (method == "deleteRecord")
     {
         JArray successList = (JArray)data["success"];
         JArray failList    = (JArray)data["failure"];
         DeleteRecordsDone(this, new MultipleResultEventArgs(successList, failList));
     }
     else if (method == "unsubscribe")
     {
         JArray successList = (JArray)data["success"];
         JArray failList    = (JArray)data["failure"];
         UnSubscribeDataDone(this, new MultipleResultEventArgs(successList, failList));
     }
     else if (method == "subscribe")
     {
         // UnityEngine.Debug.Log("################subscribe: ");
         JArray successList = (JArray)data["success"];
         JArray failList    = (JArray)data["failure"];
         SubscribeDataDone(this, new MultipleResultEventArgs(successList, failList));
     }
     else if (method == "injectMarker")
     {
         JObject marker = (JObject)data["marker"];
         InjectMarkerOK(this, marker);
     }
     else if (method == "updateMarker")
     {
         JObject marker = (JObject)data["marker"];
         UpdateMarkerOK(this, marker);
     }
     else if (method == "getDetectionInfo")
     {
         GetDetectionInfoDone(this, (JObject)data);
     }
     else if (method == "getCurrentProfile")
     {
         if (data["name"] == null)
         {
             GetCurrentProfileDone(this, "");
         }
         else
         {
             GetCurrentProfileDone(this, (string)data["name"]);
         }
     }
     else if (method == "setupProfile")
     {
         string action      = (string)data["action"];
         string profileName = (string)data["name"];
         if (action == "create")
         {
             CreateProfileOK(this, profileName);
         }
         else if (action == "load")
         {
             LoadProfileOK(this, profileName);
         }
         else if (action == "save")
         {
             SaveProfileOK(this, profileName);
         }
         else if (action == "unload")
         {
             UnloadProfileDone(this, true);
         }
         else if (action == "rename")
         {
             RenameProfileOK(this, profileName);
         }
         else if (action == "delete")
         {
             DeleteProfileOK(this, profileName);
         }
     }
     else if (method == "queryProfile")
     {
         QueryProfileOK(this, (JArray)data);
     }
     else if (method == "training")
     {
         TrainingOK(this, (JObject)data);
     }
     else if (method == "getTrainingTime")
     {
         GetTrainingTimeDone(this, (double)data["time"]);
     }
 }