コード例 #1
0
        /// <summary>
        /// Sends conversion event to Optimizely.
        /// </summary>
        /// <param name="eventKey">Event key representing the event which needs to be recorded</param>
        /// <param name="userId">ID for user</param>
        /// <param name="userAttributes">Attributes of the user</param>
        /// <param name="eventTags">eventTags array Hash representing metadata associated with the event.</param>
        public void Track(string eventKey, string userId, UserAttributes userAttributes = null, EventTags eventTags = null)
        {
            if (!IsValid)
            {
                Logger.Log(LogLevel.ERROR, "Datafile has invalid format. Failing 'track'.");
                return;
            }

            var inputValues = new Dictionary <string, string>
            {
                { USER_ID, userId },
                { EVENT_KEY, eventKey }
            };

            if (!ValidateStringInputs(inputValues))
            {
                return;
            }

            var eevent = Config.GetEvent(eventKey);

            if (eevent.Key == null)
            {
                Logger.Log(LogLevel.INFO, string.Format("Not tracking user {0} for event {1}.", userId, eventKey));
                return;
            }


            if (eventTags != null)
            {
                eventTags = eventTags.FilterNullValues(Logger);
            }

            var conversionEvent = EventBuilder.CreateConversionEvent(Config, eventKey,
                                                                     userId, userAttributes, eventTags);

            Logger.Log(LogLevel.INFO, string.Format("Tracking event {0} for user {1}.", eventKey, userId));
            Logger.Log(LogLevel.DEBUG, string.Format("Dispatching conversion event to URL {0} with params {1}.",
                                                     conversionEvent.Url, conversionEvent.GetParamsAsJson()));

            try
            {
                EventDispatcher.DispatchEvent(conversionEvent);
            }
            catch (Exception exception)
            {
                Logger.Log(LogLevel.ERROR, string.Format("Unable to dispatch conversion event. Error {0}", exception.Message));
            }

            NotificationCenter.SendNotifications(NotificationCenter.NotificationType.Track, eventKey, userId,
                                                 userAttributes, eventTags, conversionEvent);
        }
コード例 #2
0
    private void OnPlayeDamageTake(GeneralEvent e)
    {
        DamageResult result = e.data as DamageResult;

        if (result != null)
        {
            _hudController.OnPlayerHealthChange(result.newHealth);
            if (_playerCombatController.isDead)
            {
                _dispatcher.DispatchEvent(GameplayEventType.GAME_COMPLETE, false, false);
            }
        }
    }
コード例 #3
0
        /// <inheritdoc />
        public async Task <MetadataDefinitionDto> HandleResult(AddValidatorCommand command, CancellationToken token)
        {
            var definition = _dynamicMetadataDefinitionService.GetById(command.DefinitionId);

            if (definition == null)
            {
                throw new NotFoundException();
            }


            var validatorConfiguration = _mapper.Map <ValidatorConfiguration>(command.ValidatorData);

            validatorConfiguration.ValidatorId = Guid.NewGuid().ToString();

            bool result = _validationFactory.CreateValidatorFor(validatorConfiguration, definition);

            if (!result)
            {
                throw new BadRequestException("Validator has invalid configuration");
            }

            definition.Validators.Add(validatorConfiguration);
            _dynamicMetadataDefinitionWriteService.UpdateItem(definition, token);

            await _eventDispatcher.DispatchEvent(new RefreshValidationEvent
            {
                DefinitionId = definition.Id
            });

            return(_mapper.Map <MetadataDefinitionDto>(definition));
        }
コード例 #4
0
        async Task IConfigurationStorage.SaveChanges(
            Models.Client.ConfigurationSettings configurationSettings)
        {
            await _configurationStorage.SaveChanges(configurationSettings).ConfigureAwait(false);

            _eventDispatcher.DispatchEvent(new ViewEvents.ConfigurationSettingsSaved());
        }
コード例 #5
0
        /// <inheritdoc />
        public async Task <MetadataDefinitionDto> HandleResult(RemoveValidatorCommand command, CancellationToken token)
        {
            var definition = _dynamicMetadataDefinitionService.GetById(command.DefinitionId);

            if (definition == null)
            {
                throw new NotFoundException();
            }

            var validator = definition.Validators.FirstOrDefault(x => x.ValidatorId == command.ValidatorId);

            if (validator == null)
            {
                throw new NotFoundException();
            }

            definition.Validators.Remove(validator);
            _dynamicMetadataDefinitionWriteService.UpdateItem(definition, token);

            await _eventDispatcher.DispatchEvent(new RefreshValidationEvent
            {
                DefinitionId = definition.Id
            });

            return(_mapper.Map <MetadataDefinitionDto>(definition));
        }
コード例 #6
0
        /// <inheritdoc />
        public async Task <MetadataDefinitionDto> HandleResult(UpdateValidatorConfigurationCommand command, CancellationToken token)
        {
            var definition = _dynamicMetadataDefinitionService.GetById(command.DefinitionId);

            if (definition == null)
            {
                throw new NotFoundException();
            }

            var validator = definition.Validators.FirstOrDefault(x => x.ValidatorId == command.ValidatorId);

            if (validator == null)
            {
                throw new NotFoundException();
            }

            validator.Parameters = command.ValidatorConfiguration.Parameters;
            bool result = _validationFactory.CreateValidatorFor(validator, definition);

            if (!result)
            {
                throw new BadRequestException("Validator has invalid configuration");
            }

            _dynamicMetadataDefinitionWriteService.UpdateItem(definition, token);

            await _eventDispatcher.DispatchEvent(new RefreshValidationEvent
            {
                DefinitionId = definition.Id
            });

            return(_mapper.Map <MetadataDefinitionDto>(definition));
        }
コード例 #7
0
 /// <summary>
 /// Dispatches the module event.
 /// </summary>
 /// <param name="evt">The event object.</param>
 public void DispatchModuleEvent(Event evt)
 {
     if (m_moduleEventDispatcher != null)
     {
         m_moduleEventDispatcher.DispatchEvent(evt);
     }
 }
コード例 #8
0
 /// <summary>
 /// Dispatches the global event.
 /// </summary>
 /// <param name="evt">The event object.</param>
 public void Dispatch(Event evt)
 {
     if (m_contextEventDispatcher != null)
     {
         m_contextEventDispatcher.DispatchEvent(evt);
     }
 }
コード例 #9
0
        async Task ICardDatabaseManager.UpdateCardDatabase(
            int version,
            Stream updateStream)
        {
            await _cardDatabaseManager.UpdateCardDatabase(version, updateStream).ConfigureAwait(false);

            _eventDispatcher.DispatchEvent(new ViewEvents.CardDatabaseUpdated());
        }
コード例 #10
0
        public void OnClick()
        {
            var @event = new StyleChangedEvent {
                Style = _style
            };

            _eventDispatcher.DispatchEvent(@event);
        }
コード例 #11
0
 private void onLootPickedUp(GhostGen.GeneralEvent e)
 {
     LootConfig.LootItemDef itemDef = e.data as LootConfig.LootItemDef;
     if (itemDef != null)
     {
         AddItem(itemDef.type, itemDef.GetQuantitiy());
         _dispatcher.DispatchEvent(GameplayEventType.INVENTORY_UPDATED, false, itemDef.type);
     }
 }
コード例 #12
0
    IEnumerator Start()
    {
        yield return(new WaitForSeconds(2f));

        Debug.Log("Dispatch event");
        _eventManager.DispatchEvent(new MyEvent {
            _index = 2
        });
    }
コード例 #13
0
    public DamageResult TakeDamage(object attacker, float damage)
    {
        DamageResult result = new DamageResult();

        result.prevHealth = health;
        health            = Mathf.Max(health - damage, 0.0f);
        result.newHealth  = health;
        result.victim     = this;
        result.attacker   = attacker;

        if (isDead && result.prevHealth > 0.0f)
        {
            Singleton.instance.particleGod.GenerateParticle(Particle.Type.EnemyDeath, _view.transform.position);
            Singleton.instance.audioSystem.PlaySound(SoundBank.Type.MonsterDeath, null, true);
            _view.Die();
            _dispatcher.DispatchEvent(GameplayEventType.ENEMY_KILLED, false, this);
        }
        return(result);
    }
コード例 #14
0
        public void OnClick()
        {
            var @event = new StyleChangedEvent {
                Style = _style
            };

            //here event is being fired to context and than to all of it's dependencies
            //and gameobjects that contains Injector
            _eventDispatcher.DispatchEvent(@event);
        }
コード例 #15
0
        //this handler will actually fire off multiple events instead of just creating the payment, we should ideally refactor this with a payment service
        // and split the functionality up as the process gets more complicated.
        public async Task <Response <Guid> > Handle(CreatePaymentCommand request, CancellationToken cancellationToken)
        {
            var paymentExists = await IsPaymentDuplicate(request.Id);

            if (paymentExists)
            {
                return(Response.Failure <Guid>($"Error, a payment with id {request.Id} already exists"));
            }

            // dont need to create the payment and process the events. we can get a payment by processing the events on the fly
            // see GetPaymentHandler for details. For now just dispatch the necessary events.

            var createPaymentEvent = new CreatePaymentEvent(DateTime.UtcNow, request.Id, request.CardNumber, request.Currency, request.Amount);
            await _eventDispatcher.DispatchEvent(createPaymentEvent);


            await _eventDispatcher.DispatchEvent(new PaymentSentToAcquiringBankEvent(DateTime.UtcNow, request.Id));

            //TODO: Extract this to a config file property in appsettings.json
            var baseUrl  = "http://localhost:4000";
            var response = await _acquiringBankHttpClient.Post <Guid>($"{baseUrl}/api/AcquiringBank", new
            {
                request.CardNumber,
                request.MonthExpired,
                request.YearExpired,
                request.Ccv,
                request.Amount,
                request.Currency
            });

            if (!response.Error)
            {
                await _eventDispatcher.DispatchEvent(new PaymentSucceededEvent(DateTime.UtcNow, request.Id, response.Data));

                return(Response.Success <Guid>(response.Data, response.Message));
            }
            else
            {
                await _eventDispatcher.DispatchEvent(new PaymentFailedEvent(DateTime.UtcNow, request.Id, response.Message));

                return(Response.Failure(response.Message, response.Data));
            }
        }
コード例 #16
0
        private IEnumerable <ChunkColumn> GenerateChunks(ChunkCoordinates center, int renderDistance)
        {
            var oldChunks = _loadedChunks.ToArray();

            double radiusSquared = Math.Pow(renderDistance, 2);

            List <ChunkCoordinates> newChunkCoordinates = new List <ChunkCoordinates>();

            List <ChunkCoordinates> results = new List <ChunkCoordinates>();

            for (int y = center.Z - renderDistance; y <= center.Z + renderDistance; y++)
            {
                for (int x = center.X - renderDistance; x <= center.X + renderDistance; x++)
                {
                    var cc = new ChunkCoordinates(x, y);

                    newChunkCoordinates.Add(cc);

                    if (!_loadedChunks.Contains(cc))
                    {
                        ChunkColumn chunk =
                            _generator.GenerateChunkColumn(cc);

                        if (chunk == null)
                        {
                            continue;
                        }

                        _loadedChunks.Add(cc);

                        yield return(chunk);
                    }
                }
            }

            foreach (var chunk in oldChunks)
            {
                if (!newChunkCoordinates.Contains(chunk) && chunk != center)
                {
                    //UnloadChunk(chunk.X, chunk.Z);
                    ChunkUnloadEvent unloadEvent = new ChunkUnloadEvent(chunk);
                    EventDispatcher.DispatchEvent(unloadEvent);

                    if (!unloadEvent.IsCancelled)
                    {
                        _loadedChunks.Remove(chunk);
                    }
                }
            }
        }
コード例 #17
0
        public void Process(UserEvent userEvent)
        {
            var logEvent = EventFactory.CreateLogEvent(userEvent, Logger);

            try
            {
                EventDispatcher.DispatchEvent(logEvent);
                NotificationCenter?.SendNotifications(NotificationCenter.NotificationType.LogEvent, logEvent);
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.ERROR, $"Error dispatching event: {logEvent.GetParamsAsJson()}. {ex.Message}");
                ErrorHandler.HandleError(ex);
            }
        }
コード例 #18
0
        /// <inheritdoc />
        public async Task <MetadataDefinitionDto> HandleResult(ChangePropertyTypeAndDefaultValueCommand command, CancellationToken token)
        {
            var definition = _dynamicMetadataDefinitonService.GetById(command.DefinitionId);

            if (definition == null)
            {
                throw new NotFoundException();
            }

            var existingProperty = definition.Properties.SingleOrDefault(x => x.Id == command.PropertyKey);

            if (existingProperty == null)
            {
                throw new BadRequestException("Property doesn't already exist");
            }

            DynamicMetadataProperty property;

            try
            {
                property = _inputDataParser.DeserializeItem(command.PropertyKey, command.UpdatedObject.Type, command.UpdatedObject.DefaultValue);
            }
            catch (JsonException exception)
            {
                throw new AggregatedValidationException("Invalid type mismatch")
                      {
                          ErrorCode        = 11231,
                          ValidationErrors = new List <Error>()
                      };
            }

            // parsing property
            definition.Properties.Remove(existingProperty);
            definition.Properties.Add(property);

            _dynamicMetadataDefinitionWriteService.UpdateItem(definition, token);

            await _eventDispatcher.DispatchEvent(new PropertyDefinitionUpdatedEvent
            {
                UpdatedPropertyKey = property.Id,
                DefinitionId       = command.DefinitionId
            });

            return(_mapper.Map <MetadataDefinitionDto>(definition));
        }
コード例 #19
0
        public void ClosePopUp(IPopupMediator popupMediator)
        {
            if (_popups.Contains(popupMediator))
            {
                _popups.Remove(popupMediator);
            }

            try{
                //TODO: remove! Fallback because of old modal and other popups, remove after cleaning all old shiath
                var type = popupMediator.GetType();
                popupMediator.Destroy();
                EventDispatcher.DispatchEvent(new PopupClosedEvent(type));
            }
            catch (Exception e)
            {
                Debug.LogWarningFormat("<color=\"red\">{0} : {1}</color>", this, e);
            }
        }
コード例 #20
0
        private void Start()
        {
            var dependency = new CommandDependency();
            var evt        = new Event();

            var context = Context.Create()
                          .RegisterDependency(dependency)
                          .RegisterCommand <Event, Command>();

            IEventDispatcher dispatcher = (IEventDispatcher)context.Resolve(typeof(IEventDispatcher));

            dispatcher.DispatchEvent(evt);

            Assert.True(dependency.Executed, "command executed");
            Assert.NotNull(dependency.WithEvent, "command event setter");

            context.Destroy();
        }
コード例 #21
0
    public void FireWeapon(Vector3 targetPos)
    {
        if (_fireTimer > 0 || !isEnabled || isDead)
        {
            return;
        }

        Vector3 visualWeaponPos = _view.weaponBarrelPosition;
        Vector3 viewDir         = getFireDirection(_view._rotateTransform.forward, 0.08f);//(targetPos - visualWeaponPos).normalized;

        viewDir.y = 0;

        Vector3 adjustedPos = visualWeaponPos + (viewDir * 50.0f);

        Vector3 rayPoint = _view.viewPosition;

        rayPoint.y = visualWeaponPos.y;
        Ray ray = new Ray(visualWeaponPos, viewDir);

        Singleton.instance.audioSystem.PlaySound(SoundBank.Type.WeaponFire, null, true);

        IDamageable target;
        RaycastHit  hit;
        bool        targetFound = getTarget(ray, out hit, out target);

        if (targetFound)
        {
            Vector3 force = viewDir * 110.0f;

            DamageResult dResult = target.TakeDamage(this, _config.weapon.damage);
            _dispatcher.DispatchEvent(GameplayEventType.DAMAGE_TAKEN, false, dResult);

            if (target.physbody)
            {
                target.physbody.AddForceAtPosition(force, hit.point, ForceMode.Impulse);
            }

            adjustedPos = hit.point;
        }

        Debug.DrawRay(adjustedPos, Vector3.up, Color.red);
        _view.VisualFireWeapon(_config.weapon.bulletSpeed, adjustedPos);
        _fireTimer = _config.weapon.fireCooldown;
    }
コード例 #22
0
        private void RedispatchKeyEvent(IEventDispatcher targetComponent, ICloneable systemManagerKeyEvent)
        {
            _keyEvent        = (KeyboardEvent)systemManagerKeyEvent.Clone();
            _keyEvent.Target = targetComponent;

            /**
             * 1) Dispatch from here
             * */
            DispatchEvent(_keyEvent);

            // the event might be canceled
            if (_keyEvent.Canceled)
            {
                return;
            }

            /**
             * 2) Dispatch from the component
             * */
            targetComponent.DispatchEvent(_keyEvent);
        }
コード例 #23
0
        void IPlayerDeckTrackerInterface.TrackDeck(
            Models.Client.Decklist decklist)
        {
            Reset();

            IEventDispatcher eventDispatcher = _eventDispatcherFactory.Create();

            _viewModel =
                new PlayerDeckTrackerViewModel(
                    _cardInfoProvider,
                    _configurationSource,
                    eventDispatcher,
                    _viewEventDispatcher,
                    decklist);

            _cancellation = new CancellationTokenSource();

            Task.Run(
                async() =>
            {
                using (IEventStream eventStream = _eventStreamFactory.Create())
                {
                    while (true)
                    {
                        object @event = await eventStream.ReadNext(_cancellation.Token);
                        if (@event == null)
                        {
                            return;
                        }

                        eventDispatcher.DispatchEvent(@event);
                    }
                }
            });

            _view = new PlayerDeckTrackerView(_viewModel);

            _view.Show();
        }
コード例 #24
0
        /// <inheritdoc />
        public async Task <MetadataDefinitionDto> HandleResult(RemoveMovieMetadataCommand command, CancellationToken token)
        {
            var definition = _dynamicMetadataDefinitonService.GetById(command.MetadataDefinitionId);

            if (definition == null)
            {
                throw new NotFoundException();
            }

            var existingProperty = definition.Properties.SingleOrDefault(x => x.Id == command.MetadataKey);

            if (existingProperty == null)
            {
                throw new NotFoundException();
            }

            var validator = _validationFactory.GetValidator(definition);

            if (validator.WillUseProperty(existingProperty.Id))
            {
                throw new BadRequestException("Property is used by validator")
                      {
                          ErrorCode = 11,
                      };
            }

            definition.Properties.Remove(existingProperty);
            _dynamicMetadataDefinitionWriteService.UpdateItem(definition, token);

            await _eventDispatcher.DispatchEvent(new PropertyRemovedFromMetadataDefinitionEvent
            {
                RemovedPropertyKey = command.MetadataKey,
                DefinitionId       = command.MetadataDefinitionId
            });

            return(_mapper.Map <MetadataDefinitionDto>(definition));
        }
コード例 #25
0
 protected void DispatchEvent <TEvent>(TEvent e) where TEvent : AbstractEvent
 {
     EventDispatcher.DispatchEvent(e);
 }
コード例 #26
0
 public void ReceiveEvent(Event @event)
 {
     dispatcher.DispatchEvent(@event);
 }
コード例 #27
0
 /// <summary>
 /// As Commands should not listen to events but just dispatch them,
 /// this only way how they need to interact with dispatcher
 /// </summary>
 /// <param name="e"></param>
 protected void DispatchEvent <T>(T e) where T : AbstractEvent
 {
     _eventDispatcher.DispatchEvent(e);
 }
コード例 #28
0
        private void RedispatchKeyEvent(IEventDispatcher targetComponent, ICloneable systemManagerKeyEvent)
        {
            _keyEvent = (KeyboardEvent)systemManagerKeyEvent.Clone();
            _keyEvent.Target = targetComponent;
            
            /**
             * 1) Dispatch from here
             * */
            DispatchEvent(_keyEvent);

            // the event might be canceled
            if (_keyEvent.Canceled)
                return;

            /**
             * 2) Dispatch from the component
             * */
            targetComponent.DispatchEvent(_keyEvent);
        }
コード例 #29
0
ファイル: Artikel.cs プロジェクト: gingters/services_sample
 public void ApplyEvent(IEvent evt)
 {
     _eventDispatcher.DispatchEvent(this, evt);
     Version++;
 }
コード例 #30
0
ファイル: MenuScreen.cs プロジェクト: dyskotron/Framewerk
        private void MenuItemClickedHandler(ListItemClickedEvent e)
        {
            var item = _menuPanelList.GetDataproviderAt(e.ItemIndex);

            _eventDispatcher.DispatchEvent(new MenuItemSelectedEvent(item.ItemIdId));
        }
コード例 #31
0
ファイル: Armature.cs プロジェクト: GreySky0012/AfterDeath
        /**
         * @language zh_CN
         * 更新骨架和动画。
         * @param passedTime 两帧之间的时间间隔。 (以秒为单位)
         * @see DragonBones.IAnimateble
         * @see DragonBones.WorldClock
         * @version DragonBones 3.0
         */
        public void AdvanceTime(float passedTime)
        {
            if (_armatureData == null)
            {
                DragonBones.Assert(false, "The armature has been disposed.");
                return;
            }
            else if (_armatureData.parent == null)
            {
                DragonBones.Assert(false, "The armature data has been disposed.");
                return;
            }

            // Bones and slots.
            if (_bonesDirty)
            {
                _bonesDirty = false;
                _sortBones();
            }

            if (_slotsDirty)
            {
                _slotsDirty = false;
                _sortSlots();
            }

            var prevCacheFrameIndex = _animation._cacheFrameIndex;

            // Update animations.
            _animation._advanceTime(passedTime);

            var currentCacheFrameIndex = _animation._cacheFrameIndex;

            int i = 0, l = 0;

            if (currentCacheFrameIndex < 0 || currentCacheFrameIndex != prevCacheFrameIndex)
            {
                // Update bones.
                for (i = 0, l = _bones.Count; i < l; ++i)
                {
                    var bone = _bones[i];
                    bone._update(currentCacheFrameIndex);
                }

                // Update slots.
                for (i = 0, l = _slots.Count; i < l; ++i)
                {
                    _slots[i]._update(currentCacheFrameIndex);
                }
            }

            //
            if (!_lockDispose)
            {
                _lockDispose = true;

                // Events. (Dispatch event before action.)
                l = _events.Count;
                if (l > 0)
                {
                    for (i = 0; i < l; ++i)
                    {
                        var eventObject = _events[i];
                        _proxy.DispatchEvent(eventObject.type, eventObject);

                        if (eventObject.type == EventObject.SOUND_EVENT)
                        {
                            _eventManager.DispatchEvent(eventObject.type, eventObject);
                        }

                        eventObject.ReturnToPool();
                    }

                    _events.Clear();
                }

                // Actions.
                l = _actions.Count;
                if (l > 0)
                {
                    for (i = 0; i < l; ++i)
                    {
                        var action = _actions[i];
                        if (action.slot != null)
                        {
                            var slot = GetSlot(action.slot.name);
                            if (slot != null)
                            {
                                var childArmature = slot.childArmature;
                                if (childArmature != null)
                                {
                                    childArmature._doAction(action);
                                }
                            }
                        }
                        else if (action.bone != null)
                        {
                            for (int iA = 0, lA = _slots.Count; iA < lA; ++iA)
                            {
                                var childArmature = _slots[iA].childArmature;
                                if (childArmature != null)
                                {
                                    childArmature._doAction(action);
                                }
                            }
                        }
                        else
                        {
                            _doAction(action);
                        }
                    }

                    _actions.Clear();
                }

                _lockDispose = false;
            }

            if (_delayDispose)
            {
                ReturnToPool();
            }
        }