Пример #1
0
 internal override UserToUserResponse ProcessWithEngagement(Engagement engagement, UserToUserRequest req)
 {
     ListenHandshakeRq request = (ListenHandshakeRq)req;
     ListenHandshakeRs response = new ListenHandshakeRs();
     try
     {
         var peerInfo = new PeerInfo()
             {
                 ExternalEndPoint =
                     request.externalEndPoint != null ? new IPEndPoint(IPAddress.Parse(request.externalEndPoint.address),
                                    request.externalEndPoint.port) : null,
             };
         foreach (var ipEndPointElement in request.internalEndPoints)
         {
             peerInfo.InternalEndPoints.Add(new IPEndPoint(IPAddress.Parse(ipEndPointElement.address), ipEndPointElement.port));
         }
         _appContext.P2PManager.ReceiveP2PTunnel(request.uniqueId, peerInfo);
     }
     catch (Exception e)
     {
         Logger.Error("Failed to start listening for UDP traffic from peer : " + e.Message,e);
         response.error = "LISTEN_ERROR";
         response.errorMessage = "Failed to start listening for UDP traffic";
     }
     return response;
 }
Пример #2
0
    private string GetTweetForEngagement(Engagement engagement)
    {
        // TODO: Account for custom images for engagement
        // TODO: Account for custom message for engagement
        //  i.e: Join me tomorrow, Join me next week
        // TODO: Maybe handle timezone?
        if (engagement is null)
        {
            return(null);
        }

        var statusText = $"I'm speaking at {engagement.Name} ({engagement.Url}) starting on {engagement.StartDateTime:f}";
        var comments   = engagement.Comments;

        statusText += " " + comments;

        if (statusText.Length + comments.Length + 1 >= MaxTweetLength)
        {
            var newLength = MaxTweetLength - statusText.Length - comments.Length - 1;
            statusText = statusText.Substring(0, newLength - 4) + "...";
        }

        _logger.LogDebug("Composed tweet '{statusText}'", statusText);
        return(statusText);
    }
        ////////////////////////////////////////////////////////////////////
        // Publisher MetaGame Engage Campaign Check
        ////////////////////////////////////////////////////////////////////
        public void MetaGameRequestEngagement(Engagement engagement, Action <Engagement> onCompleted, Action <Exception> onError)
        {
            DeltaDNA.Logger.LogDebug("MetaGame Campaign Check Click");
            if (String.IsNullOrEmpty(ENGAGE_REST_API_URL))
            {
                throw new Exception("Engage URL not configured.");
            }

            try
            {
                var dict = engagement.AsDictionary();

                var request = new EngageRequest(dict["decisionPoint"] as string);
                request.Flavour    = dict["flavour"] as string;
                request.Parameters = dict["parameters"] as Dictionary <string, object>;

                EngageResponse handler = (string response, int statusCode, string error) => {
                    engagement.Raw        = response;
                    engagement.StatusCode = statusCode;
                    engagement.Error      = error;

                    onCompleted(engagement);
                };

                StartCoroutine(MetaGameEngageRequest(this, request, handler));
            }
            catch (Exception ex)
            {
                DeltaDNA.Logger.LogWarning("Engagement request failed: " + ex.Message);
            }
        }
Пример #4
0
        /// <summary>
        /// Insert Engagement.
        /// </summary>
        /// <param name="engagement"></param>
        /// <returns></returns>
        /// <response code="200">Returns the newly-created item</response>
        /// <response code="400">If the item is null</response>

        public IHttpActionResult Post([FromBody] Engagement engagement)
        {
            try
            {
                List <string> errors = ValidateExtensions.ValidateEngagements(engagement);

                if (errors.Count > 0)
                {
                    return(Content(HttpStatusCode.BadRequest, errors));
                }

                engagement.Team     = TimeUnit.Teams.Get(engagement.Team.Id);
                engagement.Role     = TimeUnit.Roles.Get(engagement.Role.Id);
                engagement.Employee = TimeUnit.Employees.Get(engagement.Employee.Id);

                TimeUnit.Engagements.Insert(engagement);
                TimeUnit.Save();
                Utility.Log($"ENGAGEMENT CONTROLLER: Post Called on Engagement, Successfully added: {engagement.Id}.", "INFO");
                return(Ok(TimeFactory.Create(engagement)));
            }

            catch (Exception ex)

            {
                Utility.Log($"ENGAGEMENT CONTROLLER: Post Cannot be called on Engagement.", "ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
Пример #5
0
        public bool AddEngagement(Engagement engagement)
        {
            AbstractGenericOperation ado = new AddEngagementSO();
            bool success = (bool)ado.ExecuteSO(engagement);

            return(success);
        }
Пример #6
0
 public void ValidateEngagementOnCreate(Engagement engagement)
 {
     ValidateEngagement(engagement);
     ValidateEngagementInts(engagement);
     ValidateEngagementDates(engagement);
     ValidateDateRange(engagement);
 }
Пример #7
0
 internal EngagementWindow(GwupeClientAppContext appContext, DispatchingCollection <ObservableCollection <Notification>, Notification> notificationList, Engagement engagement)
 {
     InitializeComponent();
     _appContext = appContext;
     Engagement  = engagement;
     engagement.PropertyChanged += EngagementOnPropertyChanged;
     try
     {
         ((Components.Functions.RemoteDesktop.Function)Engagement.GetFunction("RemoteDesktop")).Server.ServerConnectionOpened += EngagementOnRDPConnectionAccepted;
         ((Components.Functions.RemoteDesktop.Function)Engagement.GetFunction("RemoteDesktop")).Server.ServerConnectionClosed += EngagementOnRDPConnectionClosed;
     }
     catch (Exception e)
     {
         Logger.Error("Failed to link into function RemoteDesktop : " + e.Message, e);
     }
     _notificationView = new CollectionViewSource {
         Source = notificationList
     };
     _notificationView.Filter += NotificationFilter;
     _notificationView.View.Refresh();
     notificationList.CollectionChanged += NotificationListOnCollectionChanged;
     //SetTunnelIndicator(Engagement.IncomingTunnel, IncomingTunnelIndicator);
     //SetTunnelIndicator(Engagement.OutgoingTunnel, OutgoingTunnelIndicator);
     ShowChat();
     _ewDataContext = new EngagementWindowDataContext(_appContext, engagement);
     DataContext    = _ewDataContext;
 }
        public IHttpActionResult Post([FromBody] Engagement engagement)
        {
            var errors = engagement.Validate();

            if (errors.Count > 0)
            {
                string combindedString = string.Join(" ", errors.ToArray());
                return(BadRequest(combindedString));
            }

            engagement.Team     = TimeUnit.Teams.Get(engagement.Team.Id);
            engagement.Employee = TimeUnit.Employees.Get(engagement.Employee.Id);
            engagement.Role     = TimeUnit.Roles.Get(engagement.Role.Id);

            try
            {
                TimeUnit.Engagements.Insert(engagement);
                TimeUnit.Save();
                Utility.Log($"Inserted new engagement.", "INFO");
                return(Ok(TimeFactory.Create(engagement)));
            }
            catch (Exception ex)
            {
                Utility.Log($"Insert engagement failed.", "ERROR");
                return(BadRequest(ex.Message));
            }
        }
        internal override UserToUserResponse ProcessWithEngagement(Engagement engagement, UserToUserRequest rq)
        {
            var request = (InitRepeatedConnectionRq)rq;

            Logger.Debug("Got a request to connect to a repeated connection from " + rq.username + ", with id " + request.repeatId);
            return(new InitRepeatedConnectionRs());
        }
        public IHttpActionResult Put([FromBody] Engagement engagement, int id)
        {
            try
            {
                if (TimeUnit.Engagements.Get(id) == null)
                {
                    Utility.Log($"Update engagement failed. Wrong id.", "ERROR");
                    return(NotFound());
                }

                var errors = engagement.Validate();

                if (errors.Count > 0)
                {
                    string combindedString = string.Join(" ", errors.ToArray());
                    return(BadRequest(combindedString));
                }

                TimeUnit.Engagements.Update(engagement, id);
                TimeUnit.Save();
                Utility.Log($"Updated engagement with id " + id + ".", "INFO");
                return(Ok(TimeFactory.Create(engagement)));
            }
            catch (Exception ex)
            {
                Utility.Log($"Update engagement failed.", "ERROR");
                return(BadRequest(ex.Message));
            }
        }
        public async Task <IActionResult> PostEngagement(Engagement item)
        {
            _context.Engagements.Add(item);
            await _context.SaveChangesAsync();

            return(StatusCode(201));
        }
        internal override UserToUserResponse ProcessWithEngagement(Engagement engagement, UserToUserRequest req)
        {
            ListenHandshakeRq request  = (ListenHandshakeRq)req;
            ListenHandshakeRs response = new ListenHandshakeRs();

            try
            {
                var peerInfo = new PeerInfo()
                {
                    ExternalEndPoint =
                        request.externalEndPoint != null ? new IPEndPoint(IPAddress.Parse(request.externalEndPoint.address),
                                                                          request.externalEndPoint.port) : null,
                };
                foreach (var ipEndPointElement in request.internalEndPoints)
                {
                    peerInfo.InternalEndPoints.Add(new IPEndPoint(IPAddress.Parse(ipEndPointElement.address), ipEndPointElement.port));
                }
                _appContext.P2PManager.ReceiveP2PTunnel(request.uniqueId, peerInfo);
            }
            catch (Exception e)
            {
                Logger.Error("Failed to start listening for UDP traffic from peer : " + e.Message, e);
                response.error        = "LISTEN_ERROR";
                response.errorMessage = "Failed to start listening for UDP traffic";
            }
            return(response);
        }
        ///////////////////////////////////////////////////////////////////////////
        // Award a gift to the player based on the response from an Engage campaign
        private void AwardGiftFromEngage(Engagement response)
        {
            object parametersObject;

            if (response.JSON != null && response.JSON.TryGetValue("parameters", out parametersObject))
            {
                Dictionary <string, object> parameters = parametersObject as Dictionary <string, object>;

                if (parameters.ContainsKey("virtualCurrencyName") && parameters.ContainsKey("virtualCurrencyAmount"))
                {
                    // Looking for virtualCurrencyName == coins and virtualCurrencyAMount > 0
                    if (parameters["virtualCurrencyName"] != null &&
                        parameters["virtualCurrencyAmount"] != null &&
                        parameters["virtualCurrencyName"].ToString().ToLower() == "coins" &&
                        System.Convert.ToInt32(parameters["virtualCurrencyAmount"]) > 0)
                    {
                        int coins = System.Convert.ToInt32(parameters["virtualCurrencyAmount"]);
                        this.userCoins += coins;
                        DeltaDNA.Logger.LogDebug("Gifting player " + coins + " coins");
                    }
                }

                UpdatePlayerHUD();
            }
        }
    private void OnTest()
    {
        EditorUtility.DisplayProgressBar("Running Simulation", "Starting", 0);
        Engagement   engagement = new Engagement();
        JunkyardUser user       = new JunkyardUser();

        engagement.RedCombatent  = participantRed01.Data.GetParticipant().GetTeam(user).Bot;
        engagement.BlueCombatent = participantBlue02.Data.GetParticipant().GetTeam(user).Bot;
        engagement.Rules         = RulesOfEngagement;
        engagement.Seed          = Seed;

        SimulatedEngagement SimulatedEngagement = new SimulatedEngagement(engagement, this);

        int step = 0;

        while (!SimulatedEngagement.Step())
        {
            EditorUtility.DisplayProgressBar("Running Simulation", "Running... (" + (++step) + ")", 0.5f);
        }

        ExportSimulation(SimulatedEngagement);
        string winner = engagement.RedCombatent == engagement.Outcome.Winner ? participantRed01.ID : participantBlue02.ID;

        EditorUtility.DisplayDialog("Complete", "Winner " + winner, "ok");
    }
Пример #15
0
        public IHttpActionResult Put([FromBody] Engagement engagement, int id)
        {
            try
            {
                Engagement oldEngagement = TimeUnit.Engagements.Get(id);
                if (oldEngagement == null)
                {
                    return(NotFound());
                }
                engagement = FillEngagementWithOldData(engagement, oldEngagement);
                //engagement.Role = TimeUnit.Roles.Get(engagement.Role.Id);
                //engagement.Team = TimeUnit.Teams.Get(engagement.Team.Id);
                //engagement.Employee = TimeUnit.Employees.Get(engagement.Employee.Id);

                //engagement.RoleId = engagement.Role.Id;
                //engagement.TeamId = engagement.Team.Id;
                //engagement.EmployeeId = engagement.Employee.Id;
                TimeUnit.Engagements.Update(engagement, id);
                TimeUnit.Save();
                Utility.Log($"Update data for ENGAGEMENT with ID = {id}", "INFO");
                return(Ok(TimeFactory.Create(engagement)));
            }
            catch (Exception ex)
            {
                Utility.Log(ex.Message, "ERROR", ex);
                return(BadRequest(ex.Message));
            }
        }
Пример #16
0
        public void OnInterstitialWithEngageBtn_Clicked()
        {
            var engagement = new Engagement("showInterstitial");

            DDNA.Instance.RequestEngagement(engagement, response => {
                var interstitialAd = InterstitialAd.Create(response);

                if (interstitialAd != null)   // Engagement didn't prevent ad from showing
                {
                    interstitialAd.OnInterstitialAdOpened += () => {
                        Debug.Log("Interstitial Ad opened its ad.");
                    };

                    interstitialAd.OnInterstitialAdFailedToOpen += (reason) => {
                        Debug.Log("Interstitial Ad failed to open its ad: " + reason);
                    };

                    interstitialAd.OnInterstitialAdClosed += () => {
                        Debug.Log("Interstitial Ad closed its ad.");
                    };

                    interstitialAd.Show();
                }
                else
                {
                    Debug.Log("Engage disabled the interstitial ad from showing.");
                }
            }, exception => {
                Debug.Log("Engage encountered an error: " + exception.Message);
            });
        }
Пример #17
0
        public void OnRewardedWithEngageBtn_Clicked()
        {
            var engagement = new Engagement("showRewardOrImage");

            engagement.AddParam("clickCount", ++clickCount);

            DDNA.Instance.RequestEngagement(engagement, response => {
                // Since ads must be specifically disabled, try to build image message
                // first. If that fails, then see if the ad had been disabled.
                var imageMessage = ImageMessage.Create(response);
                var rewardedAd   = RewardedAd.Create(response);

                if (imageMessage != null)
                {
                    Debug.Log("Got an image message.");
                    imageMessage.OnDidReceiveResources += () => {
                        imageMessage.Show();
                    };
                    imageMessage.FetchResources();
                }
                else if (rewardedAd != null)
                {
                    rewardedAd.Show();
                }
                else
                {
                    Debug.Log("Engage didn't return an image and prevented the ad from showing.");
                }
            }, exception => {
                Debug.Log("Engage encountered an error: " + exception.Message);
            });
        }
Пример #18
0
        static void getEngagements()
        {
            Console.Write("ENGAGEMENTS: ");
            DataTable rawData = Utility.OpenExcel(sourceData, "Engagements");
            int       N       = 0;

            foreach (DataRow row in rawData.Rows)
            {
                string     personName = Utility.getString(row, 2);
                Person     person     = context.People.Where(x => x.FirstName == personName).FirstOrDefault();
                string     roleName   = Utility.getString(row, 3);
                Role       role       = context.Roles.Where(x => x.Name == roleName).FirstOrDefault();
                string     teamName   = Utility.getString(row, 4);
                Team       team       = context.Teams.Where(x => x.Name == teamName).FirstOrDefault();
                Engagement eng        = new Engagement()
                {
                    StartDate = Utility.getDate(row, 0),
                    Time      = Utility.getInteger(row, 1),
                    Person    = person,
                    Role      = role,
                    Team      = team
                };
                N++;
                context.Engagements.Add(eng);
            }
            context.SaveChanges();
            Console.WriteLine(N);
        }
Пример #19
0
        public void ControllerPostEngagementValid()
        {
            var controller = new EngagementsController();

            Engagement engagement = new Engagement()
            {
                Team = new Team()
                {
                    Id = "A"
                },
                Role = new Role()
                {
                    Id = "TL"
                },
                Employee = new Employee()
                {
                    Id = 1
                },
                Hours = 4
            };

            var response = controller.Post(engagement);
            var result   = (OkNegotiatedContentResult <EngagementModel>)response;

            Assert.IsNotNull(result);
            Assert.IsNotNull(result.Content);
        }
Пример #20
0
        public async Task <IActionResult> Edit(int id, [Bind("EngId,OfficerName,Date,Time,Venue,ChairBy,Agenda,Status,MeetingMode,OtherParticipant,Remarks")] Engagement engagement)
        {
            if (id != engagement.EngId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(engagement);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EngagementExists(engagement.EngId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(engagement));
        }
Пример #21
0
    private FacebookPostStatus GetFacebookPostStatusForEngagement(Engagement engagement)
    {
        // TODO: Account for custom images for engagement
        // TODO: Account for custom message for engagement
        //  i.e: Join me tomorrow, Join me next week
        // TODO: Maybe handle timezone?
        if (engagement is null)
        {
            return(null);
        }

        var statusText = $"I'm speaking at {engagement.Name} ({engagement.Url}) starting on {engagement.StartDateTime:f}\n";
        var comments   = engagement.Comments;

        statusText += comments;

        if (statusText.Length + comments.Length + 1 >= MaxFacebookStatusText)
        {
            var newLength = MaxFacebookStatusText - statusText.Length - comments.Length - 1;
            statusText = statusText.Substring(0, newLength - 4) + "...";
        }

        var facebookPostStatus = new FacebookPostStatus
        {
            StatusText = statusText,
            LinkUri    = engagement.Url
        };

        _logger.LogDebug(
            "Composed Facebook Status: StatusText='{facebookPostStatus.StatusText}', LinkUrl='{facebookPostStatus.LinkUri}'",
            facebookPostStatus.StatusText, facebookPostStatus.LinkUri);
        return(facebookPostStatus);
    }
Пример #22
0
        internal string AddEngagement(Engagement engagement)
        {
            SendRequest(engagement, Operation.AddEngagement);
            Response r = (Response)formatter.Deserialize(stream);

            return(r.Message);
        }
Пример #23
0
 public void ValidateEngagement(Engagement engagement)
 {
     if (engagement is null)
     {
         throw new NullEngagementException();
     }
 }
        private string GetConnectionString(int engagementid)
        {
            string efCon = "metadata=res://*/OLTP.OLTPModel.csdl|res://*/OLTP.OLTPModel.ssdl|res://*/OLTP.OLTPModel.msl;provider=System.Data.SqlClient;";

            using (CONFIGDBContext cob = new CONFIGDBContext())
            {
                Engagement engagement                 = cob.Engagements.Where(x => x.Id == engagementid).Select(x => x).FirstOrDefault();
                var        dataSource                 = engagement.EngagementDBServerName;
                var        initialCatalog             = engagement.DBName;
                var        conUsername                = engagement.EngagementDBLogin;
                var        conUserPWD                 = "S!wan@2461511809";
                var        EngDBConnTimeout           = 300;
                SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder
                {
                    DataSource               = dataSource,
                    InitialCatalog           = initialCatalog,
                    MultipleActiveResultSets = true,
                    IntegratedSecurity       = false,
                    UserID         = conUsername,
                    Password       = conUserPWD,
                    ConnectTimeout = EngDBConnTimeout
                };
                EntityConnectionStringBuilder builder = new EntityConnectionStringBuilder
                {
                    Provider = "System.Data.SqlClient",
                    ProviderConnectionString = sqlBuilder.ConnectionString
                };

                return(efCon + builder.ConnectionString);
            }
        }
Пример #25
0
        // Gets an engagement, creates it if its not there
        public Engagement GetNewEngagement(String username, String shortCode = null)
        {
            lock (_engagementLookupLock)
            {
                if (_engagementLookup.ContainsKey(username.ToLower()))
                {
                    return(_engagementLookup[username.ToLower()]);
                }

                Attendance servicePersonAttendance = _appContext.RosterManager.GetServicePersonAttendance(username.ToLower());
                if (servicePersonAttendance == null && shortCode != null)
                {
                    // add them temporarily
                    _appContext.RosterManager.AddAdHocPerson(username, shortCode);
                    servicePersonAttendance = _appContext.RosterManager.GetServicePersonAttendance(username.ToLower());
                }
                if (servicePersonAttendance == null)
                {
                    throw new Exception("Unable to find service person [" + username + "]");
                }
                var newEngagement = new Engagement(_appContext, servicePersonAttendance);
                newEngagement.Functions.Values.ToList().ForEach(value => value.NewActivity += (sender, args) => OnActivity(args));
                Engagements.Add(newEngagement);
                _engagementLookup[username.ToLower()] = newEngagement;
                servicePersonAttendance.Engagement    = newEngagement;
                return(_engagementLookup[username.ToLower()]);
            }
        }
Пример #26
0
        public async Task Handle_WhenEFReturnsSuccessful_ReturnCorrectEngagement()
        {
            var expectedEngagement = new Engagement
            {
                Id             = 1,
                IncidentId     = 1,
                TimeEngaged    = new DateTime(1973, 3, 3),
                TimeDisengaged = new DateTime(1974, 4, 4),
                Participant    = new Participant
                {
                    Alias = "pdimit",
                    Team  = "Sia Engineering",
                    Role  = "Crisis Manager"
                }
            };

            var serviceUnderTest = new GetEngagementHandler(await MockFactory.IncidentContext(nameof(Handle_WhenEFReturnsSuccessful_ReturnCorrectEngagement)));
            var request          = new GetEngagementRequest(1, 1, new DummyAuthenticatedUserContext());


            var result = await serviceUnderTest.Handle(request, new System.Threading.CancellationToken());


            Assert.AreEqual(expectedEngagement.Id, result.Id);
            Assert.AreEqual(expectedEngagement.TimeDisengaged, result.TimeDisengaged);
            Assert.AreEqual(expectedEngagement.TimeEngaged, result.TimeEngaged);
            Assert.AreEqual(expectedEngagement.Participant.Alias, result.Participant.Alias);
        }
Пример #27
0
        public List <Engagement> FindEngagements(Engagement ee)
        {
            AbstractGenericOperation ado = new FindEngagements();
            List <Engagement>        e   = (List <Engagement>)ado.ExecuteSO(ee);

            return(e);
        }
Пример #28
0
 public void ValidateDateRange(Engagement engagement)
 {
     if (engagement.DateFrom > engagement.DateTo)
     {
         throw new DateRangeEngagementException();
     }
 }
Пример #29
0
        public void CreateWithInvalidImageJSONReturnsNull()
        {
            var engagement = new Engagement("testDecisionPoint");
            ImageMessage imageMessage;

            engagement.Raw = "{\"transactionID\":2184816393350012928,\"image\":{\"height\":256,\"format\":\"png\",\"spritemap\":{\"background\":{\"x\":2,\"y\":38,\"width\":319,\"height\":177},\"buttons\":[{\"x\":2,\"y\":2,\"width\":160,\"height\":34},{\"x\":323,\"y\":180,\"width\":157,\"height\":35}]},\"layout\":{\"landscape\":{\"background\":{\"contain\":{\"halign\":\"center\",\"valign\":\"center\",\"left\":\"10%\",\"right\":\"10%\",\"top\":\"10%\",\"bottom\":\"10%\"},\"action\":{\"type\":\"none\",\"value\":\"\"}},\"buttons\":[{\"x\":-1,\"y\":144,\"action\":{\"type\":\"dismiss\",\"value\":\"\"}},{\"x\":160,\"y\":143,\"action\":{\"type\":\"action\",\"value\":\"reward\"}}]}},\"shim\":{\"mask\":\"dimmed\",\"action\":{\"type\":\"none\"}},\"url\":\"http://download.deltadna.net/engagements/3eef962b51f84f9ca21643ca21fb3057.png\"},\"parameters\":{\"rewardName\":\"wrench\"}}";

            imageMessage = ImageMessage.Create(engagement);
            Assert.IsNull(imageMessage);

            engagement.Raw = "{\"transactionID\":2184816393350012928,\"image\":{\"width\":512,\"format\":\"png\",\"spritemap\":{\"background\":{\"x\":2,\"y\":38,\"width\":319,\"height\":177},\"buttons\":[{\"x\":2,\"y\":2,\"width\":160,\"height\":34},{\"x\":323,\"y\":180,\"width\":157,\"height\":35}]},\"layout\":{\"landscape\":{\"background\":{\"contain\":{\"halign\":\"center\",\"valign\":\"center\",\"left\":\"10%\",\"right\":\"10%\",\"top\":\"10%\",\"bottom\":\"10%\"},\"action\":{\"type\":\"none\",\"value\":\"\"}},\"buttons\":[{\"x\":-1,\"y\":144,\"action\":{\"type\":\"dismiss\",\"value\":\"\"}},{\"x\":160,\"y\":143,\"action\":{\"type\":\"action\",\"value\":\"reward\"}}]}},\"shim\":{\"mask\":\"dimmed\",\"action\":{\"type\":\"none\"}},\"url\":\"http://download.deltadna.net/engagements/3eef962b51f84f9ca21643ca21fb3057.png\"},\"parameters\":{\"rewardName\":\"wrench\"}}";

            imageMessage = ImageMessage.Create(engagement);
            Assert.IsNull(imageMessage);

            engagement.Raw = "{\"transactionID\":2184816393350012928,\"image\":{\"width\":512,\"height\":256,\"format\":\"png\",\"layout\":{\"landscape\":{\"background\":{\"contain\":{\"halign\":\"center\",\"valign\":\"center\",\"left\":\"10%\",\"right\":\"10%\",\"top\":\"10%\",\"bottom\":\"10%\"},\"action\":{\"type\":\"none\",\"value\":\"\"}},\"buttons\":[{\"x\":-1,\"y\":144,\"action\":{\"type\":\"dismiss\",\"value\":\"\"}},{\"x\":160,\"y\":143,\"action\":{\"type\":\"action\",\"value\":\"reward\"}}]}},\"shim\":{\"mask\":\"dimmed\",\"action\":{\"type\":\"none\"}},\"url\":\"http://download.deltadna.net/engagements/3eef962b51f84f9ca21643ca21fb3057.png\"},\"parameters\":{\"rewardName\":\"wrench\"}}";

            imageMessage = ImageMessage.Create(engagement);
            Assert.IsNull(imageMessage);

            engagement.Raw = "{\"transactionID\":2184816393350012928,\"image\":{\"width\":512,\"height\":256,\"format\":\"png\",\"spritemap\":{\"background\":{\"x\":2,\"y\":38,\"width\":319,\"height\":177},\"buttons\":[{\"x\":2,\"y\":2,\"width\":160,\"height\":34},{\"x\":323,\"y\":180,\"width\":157,\"height\":35}]},\"shim\":{\"mask\":\"dimmed\",\"action\":{\"type\":\"none\"}},\"url\":\"http://download.deltadna.net/engagements/3eef962b51f84f9ca21643ca21fb3057.png\"},\"parameters\":{\"rewardName\":\"wrench\"}}";

            imageMessage = ImageMessage.Create(engagement);
            Assert.IsNull(imageMessage);

            engagement.Raw = "{\"transactionID\":2184816393350012928,\"image\":{\"width\":512,\"height\":256,\"format\":\"png\",\"spritemap\":{\"background\":{\"x\":2,\"y\":38,\"width\":319,\"height\":177},\"buttons\":[{\"x\":2,\"y\":2,\"width\":160,\"height\":34},{\"x\":323,\"y\":180,\"width\":157,\"height\":35}]},\"layout\":{\"landscape\":{\"background\":{\"contain\":{\"halign\":\"center\",\"valign\":\"center\",\"left\":\"10%\",\"right\":\"10%\",\"top\":\"10%\",\"bottom\":\"10%\"},\"action\":{\"type\":\"none\",\"value\":\"\"}},\"buttons\":[{\"x\":-1,\"y\":144,\"action\":{\"type\":\"dismiss\",\"value\":\"\"}},{\"x\":160,\"y\":143,\"action\":{\"type\":\"action\",\"value\":\"reward\"}}]}},\"shim\":{\"mask\":\"dimmed\",\"action\":{\"type\":\"none\"}}},\"parameters\":{\"rewardName\":\"wrench\"}}";

            imageMessage = ImageMessage.Create(engagement);
            Assert.IsNull(imageMessage);
        }
    void OnGUI()
    {
        GUI.skin.textField.wordWrap = true;
        GUI.skin.button.fontSize    = 24;

        int xOffset = 0;
        int yOffset = 0;

        int buttonWidth  = 300;
        int buttonHeight = 100;

        GUI.skin.box.fontSize = 36;

        GUI.Box(new Rect(50, 50, 400, 400), "Menu");


        if (GUI.Button(new Rect(yOffset += 110, xOffset += 110, buttonWidth, buttonHeight), "Record event"))
        {
            print("Record event");
            var gameEvent = new GameEvent("options")
                            .AddParam("option", "sword")
                            .AddParam("action", "sell");

            DDNA.Instance.RecordEvent(gameEvent);
            print("You clicked me!");
        }
        //GUI.Button (new Rect (700,10,100,50), new GUIContent ("Click me", icon, "This is the tooltip"));

        if (GUI.Button(new Rect(yOffset, xOffset += 110, buttonWidth, buttonHeight), new GUIContent("Get Config", icon, configURL)))
        {
            print("Do engagement");

            var engagement = new Engagement("startMission")
                             .AddParam("missionID", "Disco Volante");

            DDNA.Instance.RequestEngagement(engagement, (response) =>
            {
                print("engagement");
                // Response is a Dictionary<string, object> of key-values returned from Engage.
                // It will be empty if no matching campaign was found or an error occurred.
                if (response.ContainsKey("parameters"))
                {
                    Dictionary <string, object> parameters = response["parameters"] as Dictionary <string, object>;
                    // Check if the reply contained the configuration URL an
                    if (parameters.ContainsKey("configURL"))
                    {
                        // assume a string is returned as the configURL
                        configURL = (string)parameters["configURL"];
                        print(configURL);
                    }
                    else
                    {
                        print("No configURL in reply");
                    }
                }
            });
        }
        GUI.Label(new Rect(yOffset, xOffset + buttonHeight, buttonWidth, buttonHeight), GUI.tooltip);
    }
Пример #31
0
 public void ShowRewardedAd(Engagement engagement)
 {
     #if UNITY_IOS && DDNA_SMARTADS
     _showRewardedAd(
         (engagement != null) ? engagement.DecisionPoint : null,
         GetParameters(engagement));
     #endif
 }
Пример #32
0
        public ActionResult DeleteConfirmed(int id)
        {
            Engagement engagement = db.Engagements.Find(id);

            db.Engagements.Remove(engagement);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #33
0
        public void CreateWithEngagementWithoutImageKeyReturnsNull()
        {
            var engagement = new Engagement("testDecisionPoint");
            engagement.Raw = "{\n\t\"transactionID\": 2184799313132298240,\n\t\"trace\": {\n\t\t\"initialState\": {\n\t\t\t\"serverNow\": 1460107947856000,\n\t\t\t\"userCreated\": 1459296000000000,\n\t\t\t\"roeLimited\": false\n\t\t},\n\t\t\"engagements\": [{\n\t\t\t\"engagementID\": 4451,\n\t\t\t\"behaviour\": 0,\n\t\t\t\"silent\": false,\n\t\t\t\"enabled\": true,\n\t\t\t\"parameterCriteria\": [],\n\t\t\t\"metricCriteria\": [],\n\t\t\t\"existingVariant\": 8800,\n\t\t\t\"existingState\": null,\n\t\t\t\"existingStateTimestamp\": null,\n\t\t\t\"existingConverted\": 0,\n\t\t\t\"parameters\": {\n\t\t\t\t\"adShowSession\": true\n\t\t\t}\n\t\t}]\n\t},\n\t\"parameters\": {\n\t\t\"adShowSession\": true,\n\t\t\"adProviders\": [{\n\t\t\t\"adProvider\": \"ADMOB\",\n\t\t\t\"eCPM\": 294,\n\t\t\t\"adUnitId\": \"ca-app-pub-4857093250239318/9840016386\"\n\t\t}],\n\t\t\"adRewardedProviders\": [{\n\t\t\t\"adProvider\": \"UNITY\",\n\t\t\t\"eCPM\": 1060,\n\t\t\t\"gameId\": \"106546\",\n\t\t\t\"testMode\": false\n\t\t}, {\n\t\t\t\"adProvider\": \"ADCOLONY\",\n\t\t\t\"eCPM\": 1323,\n\t\t\t\"appId\": \"appdd80fa453e784901bc\",\n\t\t\t\"clientOptions\": \"version:1.0,store:google\",\n\t\t\t\"zoneId\": \"vzc9a5567db2d447d29a\"\n\t\t}, {\n\t\t\t\"adProvider\": \"CHARTBOOST\",\n\t\t\t\"eCPM\": 38,\n\t\t\t\"appId\": \"56e3e633da15274fc8aa6cbf\",\n\t\t\t\"appSignature\": \"a7f6e1592a33abbcc0ac1e311d0ea1f614fefe7c\",\n\t\t\t\"location\": \"Default\"\n\t\t}, {\n\t\t\t\"adProvider\": \"VUNGLE\",\n\t\t\t\"eCPM\": 4,\n\t\t\t\"appId\": \"961178606\"\n\t\t}],\n\t\t\"adFloorPrice\": 1,\n\t\t\"adMinimumInterval\": 200,\n\t\t\"adMaxPerSession\": 20,\n\t\t\"adMaxPerNetwork\": 1,\n\t\t\"adDemoteOnRequestCode\": 1\n\t}\n}";

            ImageMessage imageMessage = ImageMessage.Create(engagement);
            Assert.IsNull(imageMessage);
        }
Пример #34
0
        public void InvalidRawJSON()
        {
            var engagement = new Engagement("testDecisionPoint");

            engagement.Raw = "Not valid JSON";

            Assert.AreEqual("Not valid JSON", engagement.Raw);
            Assert.IsNotNull(engagement.JSON);
            CollectionAssert.IsEmpty(engagement.JSON);
        }
Пример #35
0
        public void CreateAValidEngagement()
        {
            var engagement = new Engagement("testDecisionPoint");

            Assert.AreEqual("testDecisionPoint", engagement.DecisionPoint);
            Assert.AreEqual("engagement", engagement.Flavour);
            CollectionAssert.AreEquivalent(new Dictionary<string, object>() {
                    { "decisionPoint", "testDecisionPoint" },
                    { "flavour", "engagement" },
                    { "parameters", new Dictionary<string, object>() }
                }, engagement.AsDictionary());
        }
Пример #36
0
        public bool IsRewardedAdAllowed(Engagement engagement)
        {
            string decisionPoint = null;
            string engageParams = null;

            if (engagement != null && engagement.JSON != null) {
                try {
                    decisionPoint = engagement.DecisionPoint;
                    engageParams = DeltaDNA.MiniJSON.Json.Serialize(engagement.JSON[@"parameters"]);
                } catch (System.Exception) {}
            }
            return _isRewardedAdAllowed(decisionPoint, engageParams) > 0;
        }
Пример #37
0
 internal override UserToUserResponse ProcessWithEngagement(Engagement engagement, UserToUserRequest req)
 {
     RDPRequestRq request = (RDPRequestRq) req;
     RDPRequestRs response = new RDPRequestRs();
     try
     {
         ((Function)engagement.GetFunction("RemoteDesktop")).ProcessIncomingRemoteDesktopRequest(request.shortCode);
     } catch (Exception e)
     {
         Logger.Error("Failed to process incoming RDP request : " + e.Message,e);
         response.error = "INTERNAL_SERVER_ERROR";
         response.errorMessage = "Failed to process incoming RDP request";
     }
     return response;
 }
 internal override UserToUserResponse ProcessWithEngagement(Engagement engagement, UserToUserRequest req)
 {
     FileSendRequestResponseRq request = (FileSendRequestResponseRq)req;
     FileSendRequestResponseRs response = new FileSendRequestResponseRs();
     try
     {
         ((Function)engagement.GetFunction("FileSend")).ProcessFileSendRequestResponse(request.accepted,request.fileSendId);
     }
     catch (Exception e)
     {
         Logger.Error("Failed to process incoming FileSend request response : " + e.Message, e);
         response.error = "INTERNAL_SERVER_ERROR";
         response.errorMessage = "Failed to process incoming FileSend request response";
     }
     return response;
 }
Пример #39
0
 internal override UserToUserResponse ProcessWithEngagement(Engagement engagement, UserToUserRequest req)
 {
     FileSendRequestRq request = (FileSendRequestRq) req;
     FileSendRequestRs response = new FileSendRequestRs();
     try
     {
         ((Function)engagement.GetFunction("FileSend")).ProcessIncomingFileSendRequest(request.filename, request.fileSendId, request.fileSize);
     }
     catch (Exception e)
     {
         Logger.Error("Failed to process incoming File Send request : " + e.Message,e);
         response.error = "UNKNOWN_ERROR";
         response.errorMessage = "Failed to process incoming File Send request";
     }
     return response;
 }
Пример #40
0
 internal override UserToUserResponse ProcessWithEngagement(Engagement engagement, UserToUserRequest req)
 {
     ChatMessageRq request = (ChatMessageRq)req;
     ChatMessageRs response = new ChatMessageRs();
     try
     {
         ((Function)engagement.Functions["Chat"]).ReceiveChatMessage(request.message, request.chatId, request.interactionId, request.shortCode,request.username);
     }
     catch (Exception e)
     {
         Logger.Error("Failed to process chat message : " + e.Message,e);
         response.error = "UNKNOWN_ERROR";
         response.errorMessage = "Failed to process Chat request";
     }
     return response;
 }
Пример #41
0
        public static RewardedAd Create(Engagement engagement)
        {
            if (!DDNASmartAds.Instance.IsRewardedAdAllowed(engagement)) return null;

            JSONObject parameters = null;

            if (engagement != null && engagement.JSON != null) {
                if (engagement.JSON.ContainsKey("parameters")) {
                    parameters = engagement.JSON["parameters"] as JSONObject;
                }
            }

            var instance = new RewardedAd();
            instance.Parameters = parameters ?? new JSONObject();

            return instance;
        }
Пример #42
0
        public void CreateAValidEngagementWithExtraParameters()
        {
            var engagement = new Engagement("testDecisionPoint");
            engagement.AddParam("A", 1);
            engagement.AddParam("B", "two");
            engagement.AddParam("C", true);

            Assert.AreEqual("testDecisionPoint", engagement.DecisionPoint);
            Assert.AreEqual("engagement", engagement.Flavour);
            CollectionAssert.AreEquivalent(new Dictionary<string, object>() {
                    { "decisionPoint", "testDecisionPoint" },
                    { "flavour", "engagement" },
                    { "parameters", new Dictionary<string, object>() {
                            { "A", 1 },
                            { "B", "two" },
                            { "C", true }
                        }
                    }
                }, engagement.AsDictionary());
        }
Пример #43
0
 public void CreateWithInvalidEngagementResturnsNull()
 {
     var engagement = new Engagement("testDecisionPoint");
     ImageMessage imageMessage = ImageMessage.Create(engagement);
     Assert.IsNull(imageMessage);
 }
Пример #44
0
 internal Function(GwupeClientAppContext appContext, Engagement engagement)
 {
     this._appContext = appContext;
     this._engagement = engagement;
     this._to = engagement.SecondParty.Party.Username;
     SetupCommands();
     Conversation = new Conversation(appContext);
     _chatQueue = new ConcurrentQueue<SelfChatElement>();
     _chatSender = new Thread(ProcessChats) { Name = "ChatSender-" + _to, IsBackground = true };
     _chatSender.Start();
 }
Пример #45
0
 internal FileSendActivity(Engagement engagement, String activity)
     : base(engagement, "FILE_SEND", activity)
 {
 }
Пример #46
0
 internal abstract UserToUserResponse ProcessWithEngagement(Engagement engagement, UserToUserRequest request);
Пример #47
0
 internal InteractionActivity(Engagement engagement, String activity)
     : base(engagement, "INTERACTION", activity)
 {
 }
Пример #48
0
        public void CreateWithValidEngagement()
        {
            var engagement = new Engagement("testDecisionPoint");
            engagement.Raw = "{\"transactionID\":2184816393350012928,\"image\":{\"width\":512,\"height\":256,\"format\":\"png\",\"spritemap\":{\"background\":{\"x\":2,\"y\":38,\"width\":319,\"height\":177},\"buttons\":[{\"x\":2,\"y\":2,\"width\":160,\"height\":34},{\"x\":323,\"y\":180,\"width\":157,\"height\":35}]},\"layout\":{\"landscape\":{\"background\":{\"contain\":{\"halign\":\"center\",\"valign\":\"center\",\"left\":\"10%\",\"right\":\"10%\",\"top\":\"10%\",\"bottom\":\"10%\"},\"action\":{\"type\":\"none\",\"value\":\"\"}},\"buttons\":[{\"x\":-1,\"y\":144,\"action\":{\"type\":\"dismiss\",\"value\":\"\"}},{\"x\":160,\"y\":143,\"action\":{\"type\":\"action\",\"value\":\"reward\"}}]}},\"shim\":{\"mask\":\"dimmed\",\"action\":{\"type\":\"none\"}},\"url\":\"http://download.deltadna.net/engagements/3eef962b51f84f9ca21643ca21fb3057.png\"},\"parameters\":{\"rewardName\":\"wrench\"}}";

            Assert.IsNotNull(engagement.JSON);
            Assert.Contains("image", engagement.JSON.Keys);
            Assert.Contains("parameters", engagement.JSON.Keys);

            ImageMessage imageMessage = ImageMessage.Create(engagement);
            Assert.IsNotNull(imageMessage);

            Assert.That(!imageMessage.IsReady());
            Assert.That(!imageMessage.IsShowing());

            Assert.IsNotNull(imageMessage.Parameters);
            Assert.AreEqual(imageMessage.Parameters, new System.Collections.Generic.Dictionary<string, object>() {{"rewardName", "wrench"}});
        }
Пример #49
0
 internal ServiceCompleteChatElement(Engagement engagement)
 {
     _engagement = engagement;
     _interactionId = engagement.Interactions.CurrentOrNewInteraction.Id;
 }
Пример #50
0
        public void ValidRawJSON()
        {
            var engagement = new Engagement("testDecisionPoint");

            engagement.Raw = "{\"x\": 1,\"y\": \"Hello\",\"z\": [{\"1\": \"a\"}]}";

            Assert.IsNotNull(engagement.JSON);
            CollectionAssert.IsNotEmpty(engagement.JSON);
            CollectionAssert.AreEquivalent(new Dictionary<string, object>() {
                { "x", 1 },
                { "y", "Hello" },
                { "z", new List<object>() {
                        new Dictionary<string, object>() {
                            { "1", "a" }
                        }
                    }
                }
            }, engagement.JSON);
        }
Пример #51
0
 public static ImageMessage Create(Engagement engagement)
 {
     return Create(engagement, null);
 }
Пример #52
0
 internal RemoteDesktopActivity(Engagement engagement, String activity)
     : base(engagement, "REMOTE_DESKTOP", activity)
 {
 }
Пример #53
0
 internal ChatActivity(Engagement engagement, String activity)
     : base(engagement, "CHAT", activity)
 {
 }
Пример #54
0
 internal override UserToUserResponse ProcessWithEngagement(Engagement engagement, UserToUserRequest rq)
 {
     var request = (InitRepeatedConnectionRq) rq;
     Logger.Debug("Got a request to connect to a repeated connection from " + rq.username + ", with id " + request.repeatId);
     return new InitRepeatedConnectionRs();
 }
Пример #55
0
        public bool IsInterstitialAdAllowed(Engagement engagement)
        {
            string parameters = null;
            if (engagement != null && engagement.JSON != null && engagement.JSON.ContainsKey("parameters")) {
                try {
                    parameters = DeltaDNA.MiniJSON.Json.Serialize(engagement.JSON["parameters"]);
                } catch (System.Exception e) {
                    DeltaDNA.Logger.LogDebug("Exception serialising Engagement response parameters: " + e.Message);
                }
            }

            return adService.Call<bool>(
                "isInterstitialAdAllowed",
                (engagement != null) ? engagement.DecisionPoint : null,
                (parameters != null) ? new AndroidJavaObject(Utils.JSONObjectClassName, parameters) : null);
        }
Пример #56
0
 internal Function(GwupeClientAppContext appContext, Engagement engagement)
 {
     _appContext = appContext;
     _engagement = engagement;
 }
Пример #57
0
        public static ImageMessage Create(Engagement engagement, JSONObject options)
        {
            if (engagement == null || engagement.JSON == null || !engagement.JSON.ContainsKey("image")) return null;

            string name = "Image Message";
            int depth = 0;

            if (options != null) {
                if (options.ContainsKey("name")) {
                    name = options["name"] as string;
                }
                if (options.ContainsKey("depth")) {
                    depth = (int)options["depth"];
                }
            }

            ImageMessage imageMessage = null;

            try {
                var configuration = engagement.JSON["image"] as JSONObject;
                if (ValidConfiguration(configuration)) {
                    imageMessage = new ImageMessage(configuration, name, depth);
                    if (engagement.JSON.ContainsKey("parameters")) {
                        imageMessage.Parameters = engagement.JSON["parameters"] as JSONObject;
                    }
                } else {
                    Logger.LogWarning("Invalid image message configuration.");
                }
            } catch (Exception exception) {
                Logger.LogWarning("Failed to create image message: "+exception.Message);
            }

            return imageMessage;
        }
Пример #58
0
        void OnGUI()
        {
            int x = 10;
            int y = 10;
            int width = 180;
            int height = 70;
            int space = height + 5;

            GUI.skin.textField.wordWrap = true;
            GUI.skin.button.fontSize = 18;

            if (GUI.Button(new Rect(x, y, width, height), "Simple Event")) {

            GameEvent gameEvent = new GameEvent("options")
                .AddParam("option", "sword")
                .AddParam("action", "sell");

            DDNA.Instance.RecordEvent(gameEvent);

            }

            if (GUI.Button(new Rect(x, y += space, width, height), "Achievement Event")) {

            GameEvent gameEvent = new GameEvent("achievement")
                .AddParam("achievementName", "Sunday Showdown Tournament Win")
                .AddParam("achievementID", "SS-2014-03-02-01")
                .AddParam("reward", new Params()
                    .AddParam("rewardName", "Medal")
                    .AddParam("rewardProducts", new Product()
                        .AddVirtualCurrency("VIP Points", "GRIND", 20)
                        .AddItem("Sunday Showdown Medal", "Victory Badge", 1)
                    )
                );

            DDNA.Instance.RecordEvent(gameEvent);

            }

            if (GUI.Button(new Rect(x, y += space, width, height), "Transaction Event")) {

                Transaction transaction = new Transaction(
                    "Weapon type 11 manual repair",
                    "PURCHASE",
                    new Product()
                        .AddItem("WeaponsMaxConditionRepair:11", "WeaponMaxConditionRepair", 5)
                        .AddVirtualCurrency("Credit", "PREMIUM", 710),
                    new Product().SetRealCurrency("USD", Product.ConvertCurrency("USD", 12.34m))) // $12.34
                .SetTransactorId("2.212.91.84:15116")
                .SetProductId("4019")
                .AddParam("paymentCountry", "GB");

            DDNA.Instance.RecordEvent(transaction);
            }

            if (GUI.Button(new Rect(x, y += space, width, height), "Engagement")) {

            var engagement = new Engagement("gameLoaded")
                .AddParam("userLevel", 4)
                .AddParam("experience", 1000)
                .AddParam("missionName", "Disco Volante");

            DDNA.Instance.RequestEngagement(engagement, (Dictionary<string,object> response) =>
            {
                popupContent = DeltaDNA.MiniJSON.Json.Serialize(response);
            });

            popupTitle = "Engage returned";
            }

            if (GUI.Button(new Rect(x, y += space, width, height), "Image Message")) {

            var engagement = new Engagement("imageMessage")
                .AddParam("userLevel", 4)
                .AddParam("experience", 1000)
                .AddParam("missionName", "Disco Volante");

            DDNA.Instance.RequestEngagement(engagement, (response) => {

                ImageMessage imageMessage = ImageMessage.Create(response);

                // Check we got an engagement with a valid image message.
                if (imageMessage != null) {
                    Debug.Log("Engage returned a valid image message.");

                    // This example will show the image as soon as the background
                    // and button images have been downloaded.
                    imageMessage.OnDidReceiveResources += () => {
                        Debug.Log("Image Message loaded resources.");
                        imageMessage.Show();
                    };

                    // Add a handler for the 'dismiss' action.
                    imageMessage.OnDismiss += (ImageMessage.EventArgs obj) => {
                        Debug.Log("Image Message dismissed by "+obj.ID);
                    };

                    // Add a handler for the 'action' action.
                    imageMessage.OnAction += (ImageMessage.EventArgs obj) => {
                        Debug.Log("Image Message actioned by "+obj.ID+" with command "+obj.ActionValue);
                    };

                    // Download the image message resources.
                    imageMessage.FetchResources();
                }
                else {
                    Debug.Log("Engage didn't return an image message.");
                }

            }, (exception) => {
                Debug.Log("Engage reported an error: "+exception.Message);
            });
            }

            if (GUI.Button(new Rect(x, y += space, width, height), "Notification Opened")) {
            var payload = new Dictionary<string, object>();
            payload.Add("_ddId", 1);
            payload.Add("_ddName", "Example Notification");
            payload.Add("_ddLaunch", true);
            DDNA.Instance.RecordPushNotification(payload);
            }

            if (GUI.Button(new Rect(x, y += space, width, height), "Upload Events")) {
            DDNA.Instance.Upload();
            }

            if (GUI.Button(new Rect(x, y += space, width, height), "Start SDK")) {
            DDNA.Instance.StartSDK(ENVIRONMENT_KEY, COLLECT_URL, ENGAGE_URL);
            }

            if (GUI.Button(new Rect(x, y += space, width, height), "Stop SDK")) {
            DDNA.Instance.StopSDK();
            }

            if (GUI.Button(new Rect(x, y += space, width, height), "New Session")) {
            DDNA.Instance.NewSession();
            }

            if (popupContent != "") {
            GUI.ModalWindow(0, new Rect(Screen.width/2-150, Screen.height/2-100, 300, 200), RenderPopupContent, popupTitle);
            }
        }