示例#1
0
        internal void SendRequest(MATUrlBuilder.URLInfo urlInfo)
        {
            this.currentUrlInfo = urlInfo;
            string url = urlInfo.url + "&sdk_retry_attempt=" + urlInfo.retryAttempt;
            //string url = "https://877.debug.engine.mobileapptracking.com/junk"; //For debugging purposes

            /*request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";

            // Write the request Asynchronously
            using (var stream = await Task.Factory.FromAsync<Stream>(request.BeginGetRequestStream,
                                                                     request.EndGetRequestStream, null))
            {
                //create some json string
                string json = "{ \"my\" : \"json\" }";

                // convert json to byte array
                byte[] jsonAsBytes = Encoding.UTF8.GetBytes(json);

                // Write the bytes to the stream
                await stream.WriteAsync(jsonAsBytes, 0, jsonAsBytes.Length);
            }*/

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            request.BeginGetResponse(GetUrlCallback, request);
        }
示例#2
0
        // Add a url to event queue to send later
        internal void AddToQueue(MATUrlBuilder.URLInfo url) 
        {
            lock (syncLock)
            {
                if (queueThread == null || !queueThread.IsAlive)
                {
                    queueThread = new Thread(delegate() //Start on separate thread to avoid UI slowdown
                    {
                        List<MATUrlBuilder.URLInfo> eventQueue;
                        // Get existing event queue or create new one
                        if (IsolatedStorageSettings.ApplicationSettings.Contains(MATConstants.SETTINGS_MATEVENTQUEUE_KEY) &&
                            IsolatedStorageSettings.ApplicationSettings[MATConstants.SETTINGS_MATEVENTQUEUE_KEY].GetType() == typeof(List<MATUrlBuilder.URLInfo>))
                        {
                            eventQueue = (List<MATUrlBuilder.URLInfo>)IsolatedStorageSettings.ApplicationSettings[MATConstants.SETTINGS_MATEVENTQUEUE_KEY];
                        }
                        else // No existing queue, create
                        {
                            IsolatedStorageSettings.ApplicationSettings.Remove(MATConstants.SETTINGS_MATEVENTQUEUE_KEY);
                            eventQueue = new List<MATUrlBuilder.URLInfo>();
                        }

                        eventQueue.Add(url);
                        SaveLocalSetting(MATConstants.SETTINGS_MATEVENTQUEUE_KEY, eventQueue);
                    });
                    queueThread.Start();
                }
            }
        }
示例#3
0
 // Add a url to event queue to send later
 internal void ProcessTrackingRequest(string action, string eventName, double revenue, string currency, string refId, List <MATEventItem> eventItems, MATParameters paramCopy)
 {
     Debug.WriteLine("Processing tracking request");
     lock (syncLock)
     {
         Task.Factory.StartNew(() =>
         {
             DumpQueue();
             string url = MATUrlBuilder.BuildUrl(action, eventName, revenue, currency, refId, eventItems, paramCopy);
             AddToQueue(url, 0);
             DumpQueue();
         });
     }
 }
        // Add a url to event queue to send later
        internal void ProcessTrackingRequest(string action, string eventName, double revenue, string currency, string refId, List <MATEventItem> eventItems, MATParameters paramCopy)
        {
            Debug.WriteLine("Processing tracking request");
            lock (syncLock)
            {
                Task.Factory.StartNew(() =>
                {
                    DumpQueue();
                    string url = MATUrlBuilder.BuildUrl(action, eventName, revenue, currency, refId, eventItems, paramCopy);
                    // Convert event items to correct JSON
                    var jsonData = JsonConvert.SerializeObject(new { data = eventItems }, Formatting.None);

                    AddToQueue(url, jsonData, 0);
                    DumpQueue();
                });
            }
        }
示例#5
0
        internal void ProcessTrackingRequest(string action, string eventName, double revenue, string currency, string refId, List <MATEventItem> eventItems, Parameters copy)
        {
            lock (syncLock)
            {
                if (queueThread == null || !queueThread.IsAlive)
                {
                    queueThread = new Thread(delegate() //Start on separate thread to avoid slowdown
                    {
                        DumpQueue();                    //Clear anything from the last dump
                        List <MATUrlBuilder.URLInfo> eventQueue;
                        // Get existing event queue or create new one
                        if (IsolatedStorageSettings.ApplicationSettings.Contains(SETTINGS_MATEVENTQUEUE_KEY) &&
                            IsolatedStorageSettings.ApplicationSettings[SETTINGS_MATEVENTQUEUE_KEY].GetType() == typeof(List <MATUrlBuilder.URLInfo>))
                        {
                            eventQueue = (List <MATUrlBuilder.URLInfo>)IsolatedStorageSettings.ApplicationSettings[SETTINGS_MATEVENTQUEUE_KEY];
                        }
                        else // No existing queue, create
                        {
                            IsolatedStorageSettings.ApplicationSettings.Remove(SETTINGS_MATEVENTQUEUE_KEY);
                            eventQueue = new List <MATUrlBuilder.URLInfo>();
                        }

                        MATUrlBuilder.URLInfo url = MATUrlBuilder.BuildUrl(action, eventName, revenue, currency, refId, eventItems, copy);
                        eventQueue.Add(url);
                        SaveLocalSetting(SETTINGS_MATEVENTQUEUE_KEY, eventQueue);

                        if (parameters.matResponse != null)
                        {
                            parameters.matResponse.EnqueuedActionWithRefId(refId);
                        }

                        DumpQueue();
                    });
                    queueThread.Start();
                }
            }
        }