Exemple #1
0
        /// <summary>
        /// Process the battery consumption statistics reported by the Insight client.
        /// </summary>
        /// <param name="message_contents"></param>
        /// <param name="client"></param>
        /// <param name="dbEntrySessionInfo"></param>
        /// <returns></returns>
        private DbEntryBattery processBatteryInfoString(string[] message_contents, TcpClient client, DbEntrySessions dbEntrySessionInfo)
        {
            try
            {
                //log.Info("Processing Battery Info String of length {0} items.", message_contents.Length);
                int indexNum = DEVICE_ID_INDEX;

                string deviceID = message_contents[indexNum++];
                int appID = Convert.ToInt32(message_contents[indexNum++]);
                string sessionID = message_contents[indexNum++];

                DbEntryBattery batteryInfo = new DbEntryBattery(appID, deviceID, sessionID);
                batteryInfo.sequenceNumber = Convert.ToInt32(message_contents[indexNum++]);
                batteryInfo.level = Convert.ToInt32(message_contents[indexNum++]);
                batteryInfo.scale = Convert.ToInt32(message_contents[indexNum++]);
                batteryInfo.temp = Convert.ToInt32(message_contents[indexNum++]);
                batteryInfo.voltage = Convert.ToInt32(message_contents[indexNum++]);
                batteryInfo.health = Convert.ToInt32(message_contents[indexNum++]);
                batteryInfo.technology = message_contents[indexNum++];
                batteryInfo.plugged = Convert.ToInt32(message_contents[indexNum++]);

                // Adding the battery technology information.
                //lock (_sessionMap)
                {
                    try
                    {
                        //DbEntrySessions dbEntrySessionInfo = _sessionMap[client];
                        dbEntrySessionInfo.batteryTechnology = batteryInfo.technology;
                    }
                    catch (Exception ex)
                    {
                        log.Error("Exception while processing battery technology information: " + batteryInfo.technology, ex);
                        return null;
                    }
                }

                return batteryInfo;
            }
            catch (Exception ex)
            {
                String msgStr = "";
                for (int i = 0; i < message_contents.Length; i++)
                {
                    msgStr += message_contents[i] + " ";
                }

                counter.msgBatteryException++;
                log.Error("Exception while processing battery information " + msgStr, ex);
                return null;
            }
        }
Exemple #2
0
        /// <summary>
        /// Process the application specific event statistics reported by the application developer through the Insight API.
        /// </summary>
        /// <param name="message_contents"></param>
        /// <param name="dbEntrySessionLocal"></param>
        public void processStatsUpdateString(string[] message_contents, DbEntrySessions dbEntrySessionLocal)
        {
            int indexNum = DEVICE_ID_INDEX;

            string deviceID = message_contents[indexNum++];
            int appID = Convert.ToInt32(message_contents[indexNum++]);
            string sessionID = message_contents[indexNum++];

            string[] stringContents = message_contents[indexNum].Split(new string[] { "$" }, StringSplitOptions.None);

            string[] eventVals = stringContents[0].Split(new string[] { "@" }, StringSplitOptions.None);
            string[] eventStrings = stringContents[1].Split(new string[] { "@" }, StringSplitOptions.None);
            string[] downloadInfo = stringContents[2].Split(new string[] { "@" }, StringSplitOptions.None);

            //log.Info("Processing " + stringContents[0] + " as eventVals");
            //log.Info("Processing " + stringContents[1] + " as eventStrings");
            //log.Info("Processing " + stringContents[2] + " as downloadInfo");

            // Adding the event-value information.
            addEventsValuesInformation(eventVals, appID, deviceID, sessionID);

            // Adding the event-value information.
            addEventStringInformation(eventStrings, appID, deviceID, sessionID);

            // Adding the download times information.
            addDownloadsInformation(downloadInfo, appID, deviceID, sessionID);
        }
Exemple #3
0
        /// <summary>
        /// Initialize a new Insight session with the input client for stats collection.
        /// </summary>
        /// <param name="message_contents"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        public DbEntrySessions initNewEntrySessionInfo(string[] message_contents, TcpClient client)
        {
            try
            {
                //log.Info("Processing Session Info String of length {0} items.", message_contents.Length);
                int indexNum = DEVICE_ID_INDEX;

                string deviceID = message_contents[indexNum++];
                int appID = Convert.ToInt32(message_contents[indexNum++]);
                string sessionID = message_contents[indexNum++];
                int platform = Convert.ToInt32(message_contents[indexNum++]);

                DbEntrySessions tempDbEntrySessions;

                lock (_sessionMap)
                {
                    if (!_sessionMap.ContainsKey(client))
                    {
                        tempDbEntrySessions = new DbEntrySessions(appID, deviceID, sessionID, platform);
                        _sessionMap[client] = tempDbEntrySessions;
                    }
                    else
                    {
                        tempDbEntrySessions = _sessionMap[client];
                    }

                    //log.Info("Added Session Item : " + _sessionMap.Count + " entries...");
                }

                return tempDbEntrySessions;
            }
            catch (Exception ex)
            {
                log.Error("Exception while processing a new initiate session entry ", ex);
                counter.msgInitSessionException++;
                return null;
            }
        }
Exemple #4
0
        /// <summary>
        /// End the existing Insight session with the input client.
        /// </summary>
        /// <param name="message_contents"></param>
        /// <param name="client"></param>
        /// <param name="dbEntrySessionInfo"></param>
        public void processEndSessionString(string[] message_contents, TcpClient client, DbEntrySessions dbEntrySessionInfo)
        {
            int indexNum = DEVICE_ID_INDEX;

            string deviceID = message_contents[indexNum++];
            int appID = Convert.ToInt32(message_contents[indexNum++]);
            string sessionID = message_contents[indexNum++];

            //log.Info("Processing " + message_contents[indexNum - 1] + "'s end session string : " + message_contents[indexNum]);

            string[] stringContents = message_contents[indexNum].Split(new string[] { "$" }, StringSplitOptions.None);

            string[] dataTransferVals = stringContents[0].Split(new string[] { "@" }, StringSplitOptions.None);
            string[] eventCounts = stringContents[1].Split(new string[] { "@" }, StringSplitOptions.None);
            string[] eventVals = stringContents[2].Split(new string[] { "@" }, StringSplitOptions.None);
            string[] eventStrings = stringContents[3].Split(new string[] { "@" }, StringSplitOptions.None);
            string[] downloadInfo = stringContents[4].Split(new string[] { "@" }, StringSplitOptions.None);

            //log.Info("Processing " + stringContents[0] + " as dataTransferVals");
            //log.Info("Processing " + stringContents[1] + " as eventCounts");
            //log.Info("Processing " + stringContents[2] + " as eventVals");
            //log.Info("Processing " + stringContents[3] + " as eventStrings");
            //log.Info("Processing " + stringContents[4] + " as downloadInfo");

            // Adding the data transfer information.
            //lock (_sessionMap)
            {
                try
                {
                    //DbEntrySessions dbEntrySessionInfo = _sessionMap[client];
                    dbEntrySessionInfo.totalTxBytes = Convert.ToInt64(dataTransferVals[0]);
                    dbEntrySessionInfo.totalRxBytes = Convert.ToInt64(dataTransferVals[1]);
                    dbEntrySessionInfo.mobileTxBytes = Convert.ToInt64(dataTransferVals[2]);
                    dbEntrySessionInfo.mobileRxBytes = Convert.ToInt64(dataTransferVals[3]);
                    dbEntrySessionInfo.appTxBytes = Convert.ToInt64(dataTransferVals[4]);
                    dbEntrySessionInfo.appRxBytes = Convert.ToInt64(dataTransferVals[5]);

                    //log.Info("Session: " + dbEntrySessionInfo);
                }
                catch (Exception ex)
                {
                    counter.msgDataTransException++;
                    log.Error("Exception Processing Data Transfer information. ", ex);
                }
            }

            // Adding the event count information.
            addEventsCountsInformation(eventCounts, appID, deviceID, sessionID);

            // Adding the event-value information.
            addEventsValuesInformation(eventVals, appID, deviceID, sessionID);

            // Adding the event-value information.
            addEventStringInformation(eventStrings, appID, deviceID, sessionID);

            // Adding the download times information.
            addDownloadsInformation(downloadInfo, appID, deviceID, sessionID);
        }
Exemple #5
0
        /// <summary>
        /// Update the application specific user ID (e.g., a user's player name within a game). It enables the developer to
        /// associate the statistics collected by Insight with the application specific user ID.
        /// </summary>
        /// <param name="message_contents"></param>
        /// <param name="dbEntrySessionInfo"></param>
        private void updateApplicationUid(string[] message_contents, DbEntrySessions dbEntrySessionInfo)
        {
            try
            {
                //log.Info("Processing Battery Info String of length {0} items.", message_contents.Length);
                int indexNum = DEVICE_ID_INDEX;

                string deviceID = message_contents[indexNum++];
                int appID = Convert.ToInt32(message_contents[indexNum++]);
                string sessionID = message_contents[indexNum++];

                string applicationUID = message_contents[indexNum++];

                if (dbEntrySessionInfo != null)
                {
                    dbEntrySessionInfo.applicationUID = applicationUID;
                }
            }
            catch (Exception ex)
            {
                String msgStr = "";
                for (int i = 0; i < message_contents.Length; i++)
                {
                    msgStr += message_contents[i] + " ";
                }

                counter.msgAppuidException++;
                log.Error("Exception while processing application UID information " + msgStr, ex);
            }
        }