SendFirstPackage() public method

public SendFirstPackage ( ) : void
return void
示例#1
0
        private void TrackEventInternal(AdjustEvent adjustEvent)
        {
            if (!IsEnabled())
            {
                return;
            }
            if (!CheckEvent(adjustEvent))
            {
                return;
            }

            var now = DateTime.Now;

            ActivityState.EventCount++;
            UpdateActivityState(now);

            var             packageBuilder = new PackageBuilder(AdjustConfig, DeviceInfo, ActivityState, now);
            ActivityPackage eventPackage   = packageBuilder.BuildEventPackage(adjustEvent);

            PackageHandler.AddPackage(eventPackage);

            if (AdjustConfig.EventBufferingEnabled)
            {
                Logger.Info("Buffered event {0}", eventPackage.Suffix);
            }
            else
            {
                PackageHandler.SendFirstPackage();
            }

            WriteActivityStateInternal();
        }
示例#2
0
        private void OpenUrlInternal(Uri uri)
        {
            if (uri == null)
            {
                return;
            }

            var sUri = Uri.UnescapeDataString(uri.ToString());

            var windowsPhone80Protocol = "/Protocol?";

            if (sUri.StartsWith(windowsPhone80Protocol))
            {
                sUri = sUri.Substring(windowsPhone80Protocol.Length);
            }

            var queryStringIdx = sUri.IndexOf("?");

            // check if '?' exists and it's not the last char
            if (queryStringIdx == -1 || queryStringIdx + 1 == sUri.Length)
            {
                return;
            }

            var queryString = sUri.Substring(queryStringIdx + 1);

            // remove any possible fragments
            var fragmentIdx = queryString.LastIndexOf("#");

            if (fragmentIdx != -1)
            {
                queryString = queryString.Substring(0, fragmentIdx);
            }

            var  queryPairs      = queryString.Split('&');
            var  extraParameters = new Dictionary <string, string>(queryPairs.Length);
            var  attribution     = new AdjustAttribution();
            bool hasAdjustTags   = false;

            foreach (var pair in queryPairs)
            {
                if (ReadQueryString(pair, extraParameters, attribution))
                {
                    hasAdjustTags = true;
                }
            }

            if (!hasAdjustTags)
            {
                return;
            }

            var clickPackage = GetDeeplinkClickPackage(extraParameters, attribution);

            PackageHandler.AddPackage(clickPackage);
            PackageHandler.SendFirstPackage();
        }
示例#3
0
        private void TransferSessionPackage()
        {
            // build Session Package
            var sessionBuilder = new PackageBuilder(AdjustConfig, DeviceInfo, ActivityState, DateTime.Now);
            var sessionPackage = sessionBuilder.BuildSessionPackage();

            // send Session Package
            PackageHandler.AddPackage(sessionPackage);
            PackageHandler.SendFirstPackage();
        }
示例#4
0
        private void TimerFiredInternal()
        {
            if (Paused())
            {
                StopTimer();
                return;
            }

            Logger.Debug("Session timer fired");
            PackageHandler.SendFirstPackage();

            if (UpdateActivityState(DateTime.Now))
            {
                WriteActivityStateInternal();
            }
        }
示例#5
0
        private void AddAndSendFirstPackageTest(PackageHandler packageHandler)
        {
            // add a package
            ActivityPackage activityPackage = CreateUnknowPackage("FirstPackage");

            // send the first package
            packageHandler.AddPackage(activityPackage);

            packageHandler.SendFirstPackage();
            DeviceUtil.Sleep(2000);

            AddPackageTests(1, "unknownFirstPackage");

            SendFirstTests(SendFirstState.SEND, "unknownFirstPackage");
        }
示例#6
0
        public void TestSendFirst()
        {
            PackageHandler.SendFirstPackage();

            DeviceUtil.Sleep(1000);

            SendFirstTests(SendFirstState.EMPTY_QUEUE);

            AddAndSendFirstPackageTest(PackageHandler);

            // try to send when it is still sending
            PackageHandler.SendFirstPackage();
            DeviceUtil.Sleep(1000);

            SendFirstTests(SendFirstState.IS_SENDING);

            // try to send paused
            PackageHandler.PauseSending();
            PackageHandler.SendFirstPackage();
            DeviceUtil.Sleep(1000);

            SendFirstTests(SendFirstState.PAUSED);

            // unpause, it's still sending
            PackageHandler.ResumeSending();
            PackageHandler.SendFirstPackage();
            DeviceUtil.Sleep(1000);

            SendFirstTests(SendFirstState.IS_SENDING);

            // verify that both paused and isSending are reset with a new session
            PackageHandler secondSessionPackageHandler = new PackageHandler(
                activityHandler: MockActivityHandler,
                startPaused: false);

            secondSessionPackageHandler.SendFirstPackage();
            DeviceUtil.Sleep(1000);

            // send the package to request handler
            SendFirstTests(SendFirstState.SEND, "unknownFirstPackage");
        }