static void SendTransactions()
        {
            cachedEvents = 0;
            //bundle up header stuff and transaction data

            //clear the transaction builder
            builder.Length = 0;

            //CognitiveVR.Util.logDebug("package transaction event data " + partCount);
            //when thresholds are reached, etc

            builder.Append("{");

            //header
            JsonUtil.SetString("userid", Core.UniqueID, builder);
            builder.Append(",");

            if (!string.IsNullOrEmpty(CognitiveVR_Preferences.LobbyId))
            {
                JsonUtil.SetString("lobbyId", CognitiveVR_Preferences.LobbyId, builder);
                builder.Append(",");
            }

            JsonUtil.SetObject("timestamp", Core.SessionTimeStamp, builder);
            builder.Append(",");
            JsonUtil.SetString("sessionid", Core.SessionID, builder);
            builder.Append(",");
            JsonUtil.SetObject("part", partCount, builder);
            partCount++;
            builder.Append(",");

            JsonUtil.SetString("formatversion", "1.0", builder);
            builder.Append(",");

            //events
            builder.Append("\"data\":[");

            builder.Append(TransactionBuilder.ToString());

            if (TransactionBuilder.Length > 0)
            {
                builder.Remove(builder.Length - 1, 1); //remove the last comma
            }
            builder.Append("]");

            builder.Append("}");

            TransactionBuilder.Length = 0;

            //send transaction contents to scene explorer

            string packagedEvents = builder.ToString();

            if (string.IsNullOrEmpty(Core.TrackingSceneId))
            {
                Util.logDebug("Instrumentation.SendTransactions could not find CurrentSceneId! has scene been uploaded and CognitiveVR_Manager.Initialize been called?");
                return;
            }

            //sends all packaged transaction events from instrumentaiton subsystem to events endpoint on scene explorer
            string url = Constants.POSTEVENTDATA(Core.TrackingSceneId, Core.TrackingSceneVersionNumber);

            //byte[] outBytes = System.Text.UTF8Encoding.UTF8.GetBytes();

            //var headers = new Dictionary<string, string>();
            //headers.Add("Content-Type", "application/json");
            //headers.Add("X-HTTP-Method-Override", "POST");

            NetworkManager.Post(url, packagedEvents);
        }
Example #2
0
        private static void SendGazeData()
        {
            if (string.IsNullOrEmpty(Core.TrackingSceneId))
            {
                Util.logDebug("Cognitive GazeCore.SendData could not find scene settings for scene! do not upload gaze to sceneexplorer");
                return;
            }

            gazebuilder.Append("],");

            gazeCount = 0;

            //header
            JsonUtil.SetString("userid", Core.UniqueID, gazebuilder);
            gazebuilder.Append(",");

            if (!string.IsNullOrEmpty(CognitiveVR_Preferences.LobbyId))
            {
                JsonUtil.SetString("lobbyId", CognitiveVR_Preferences.LobbyId, gazebuilder);
                gazebuilder.Append(",");
            }

            JsonUtil.SetDouble("timestamp", (int)Core.SessionTimeStamp, gazebuilder);
            gazebuilder.Append(",");
            JsonUtil.SetString("sessionid", Core.SessionID, gazebuilder);
            gazebuilder.Append(",");
            JsonUtil.SetInt("part", jsonPart, gazebuilder);
            jsonPart++;
            gazebuilder.Append(",");

            JsonUtil.SetString("hmdtype", HMDName, gazebuilder);

            gazebuilder.Append(",");
            JsonUtil.SetFloat("interval", CognitiveVR.CognitiveVR_Preferences.Instance.SnapshotInterval, gazebuilder);
            gazebuilder.Append(",");

            JsonUtil.SetString("formatversion", "1.0", gazebuilder);

            if (Core.GetNewSessionProperties(false).Count > 0)
            {
                gazebuilder.Append(",");
                gazebuilder.Append("\"properties\":{");
                foreach (var kvp in Core.GetNewSessionProperties(true))
                {
                    if (kvp.Value.GetType() == typeof(string))
                    {
                        JsonUtil.SetString(kvp.Key, (string)kvp.Value, gazebuilder);
                    }
                    else
                    {
                        JsonUtil.SetObject(kvp.Key, kvp.Value, gazebuilder);
                    }
                    gazebuilder.Append(",");
                }
                gazebuilder.Remove(gazebuilder.Length - 1, 1); //remove comma
                gazebuilder.Append("}");
            }
            gazebuilder.Append("}");

            var    sceneSettings = Core.TrackingScene;
            string url           = Constants.POSTGAZEDATA(sceneSettings.SceneId, sceneSettings.VersionNumber);

            CognitiveVR.NetworkManager.Post(url, gazebuilder.ToString());

            //gazebuilder = new StringBuilder(70 * CognitiveVR_Preferences.Instance.GazeSnapshotCount + 200);
            gazebuilder.Length = 9;
            //gazebuilder.Append("{\"data\":[");
        }