public void HandleEvent(ActorEvents e)
        {
            switch (e)
            {
            case ActorEvents.Started:
                this.actorLogger.ActorStarted();
                this.ScheduleTelemetry();
                break;

            case ActorEvents.SendingTelemetry:
                this.totalMessagesCount++;
                break;

            case ActorEvents.TelemetryDelivered:
                this.actorLogger.TelemetryDelivered();
                this.ScheduleTelemetry();
                break;

            case ActorEvents.TelemetryClientBroken:
                this.failedMessagesCount++;
                this.actorLogger.TelemetryFailed();
                this.deviceContext.HandleEvent(DeviceConnectionActor.ActorEvents.TelemetryClientBroken);
                this.Reset();
                break;

            case ActorEvents.TelemetrySendFailure:
                this.failedMessagesCount++;
                this.actorLogger.TelemetryFailed();
                this.ScheduleTelemetryRetry();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(e), e, null);
            }
        }
Example #2
0
    public void Out()
    {
        ActorEvents.OnPlayableStateDisabled(this.actor);

        this.combatActionsMapping.SkillSelectedMapping.ResolveSkill.performed -= this.ResolveSkillListener;
        this.combatActionsMapping.SkillSelectedMapping.CancelSkill.performed  -= this.CancelSkillListener;
    }
        public void Should_Return_CountOfFailedTwinUpdates_When_TwinUpdateFails()
        {
            // Arrange
            const int FAILED_DEVICE_TWIN_UPDATES_COUNT = 3;

            this.CreateNewDevicePropertiesActor();
            this.SetupDevicePropertiesActor();
            this.SetupRateLimitingConfig();
            this.loopSettings.Object.NewLoop(); // resets SchedulableTaggings

            // The constructor should initialize count to zero.
            Assert.Equal(0, this.target.FailedTwinUpdatesCount);

            ActorEvents deviceTwinTaggingFailed = ActorEvents.DeviceTaggingFailed;

            // Act
            for (int i = 0; i < FAILED_DEVICE_TWIN_UPDATES_COUNT; i++)
            {
                this.target.HandleEvent(deviceTwinTaggingFailed);
            }

            long failedTwinUpdateCount = this.target.FailedTwinUpdatesCount;

            // Assert
            Assert.Equal(FAILED_DEVICE_TWIN_UPDATES_COUNT, failedTwinUpdateCount);
        }
Example #4
0
    public void In()
    {
        ActorEvents.OnPlayableStateEnabled(this.actor, this.SkillUIClickListener);

        this.SwitchToSkillNotSelectedMapping();
        this.combatActionsMapping.SkillSelectedMapping.ResolveSkill.performed += this.ResolveSkillListener;
        this.combatActionsMapping.SkillSelectedMapping.CancelSkill.performed  += this.CancelSkillListener;
    }
        public void HandleEvent(ActorEvents e)
        {
            switch (e)
            {
            case ActorEvents.Started:
                this.actorLogger.ActorStarted();

                /**
                 * TODO: Devices should be tagged when created through bulk import.
                 *       Remove tagging logic.
                 */
                // TEMP DISABLED: this.status = ActorStatus.ReadyToTagDevice;
                this.status = ActorStatus.WaitingForChanges;
                break;

            case ActorEvents.DeviceTagged:
                this.actorLogger.DeviceTagged();
                this.status = ActorStatus.WaitingForChanges;
                break;

            case ActorEvents.DeviceTaggingFailed:
                if (this.loopSettings.SchedulableTaggings <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableTaggings--;

                this.failedTwinUpdatesCount++;
                this.actorLogger.DeviceTaggingFailed();
                this.ScheduleDeviceTagging();
                break;

            case ActorEvents.PropertiesUpdated:
                this.actorLogger.DevicePropertiesUpdated();
                this.status = ActorStatus.WaitingForChanges;
                break;

            case ActorEvents.PropertiesUpdateFailed:
                this.failedTwinUpdatesCount++;
                this.actorLogger.DevicePropertiesUpdateFailed();
                this.SchedulePropertiesUpdate(isRetry: true);
                break;

            case ActorEvents.PropertiesClientBroken:
                this.failedTwinUpdatesCount++;
                this.actorLogger.DevicePropertiesUpdateFailed();
                this.deviceContext.HandleEvent(DeviceConnectionActor.ActorEvents.PropertiesClientBroken);
                this.Reset();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(e), e, null);
            }
        }
        public void Handle_Event_Should_Throw_When_Out_Of_Range()
        {
            // Arrange
            const ActorEvents OUT_OF_RANGE_EVENT = (ActorEvents)123;

            this.CreateNewDevicePropertiesActor();

            // Act
            this.SetupDevicePropertiesActor();

            // Assert
            Assert.Throws <ArgumentOutOfRangeException>(
                () => this.target.HandleEvent(OUT_OF_RANGE_EVENT));
        }
        public void HandleEvent(ActorEvents e)
        {
            switch (e)
            {
            case ActorEvents.Started:
                this.actorLogger.ActorStarted();

                /**
                 * TODO: when a device is created after the initial bulk upload, the next state should be:
                 *       ActorStatus.ReadyToTagDevice
                 *       For the time being, assume all devices are created with bulk upload, which is
                 *       where the IsSimulated tag is set.
                 */
                // TEMP DISABLED: this.status = ActorStatus.ReadyToTagDevice;
                this.status = ActorStatus.WaitingForChanges;
                break;

            case ActorEvents.DeviceTagged:
                this.actorLogger.DeviceTagged();
                this.status = ActorStatus.WaitingForChanges;
                break;

            case ActorEvents.DeviceTaggingFailed:
                if (this.loopSettings.SchedulableTaggings <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableTaggings--;

                this.failedTwinUpdatesCount++;
                this.actorLogger.DeviceTaggingFailed();
                this.ScheduleDeviceTagging();
                break;

            case ActorEvents.PropertiesUpdated:
                this.actorLogger.DevicePropertiesUpdated();
                this.status = ActorStatus.WaitingForChanges;
                break;

            case ActorEvents.PropertiesUpdateFailed:
                this.failedTwinUpdatesCount++;
                this.actorLogger.DevicePropertiesUpdateFailed();
                this.SchedulePropertiesUpdate(isRetry: true);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(e), e, null);
            }
        }
Example #8
0
        public virtual void OnUnitDeath()
        {
            if (IsExcludedId || IsExcludedType || IsSameTeam)
            {
                return;
            }

            // this is not reliable for trash due to OnDestroyed()
            // disposing objects at max distance who havent really died
            // should be sufficient for progression globe waiting though.

            if (IsElite)
            {
                Core.Logger.Log(LogCategory.Targetting, $"Elite Died: {Name} Acd={AcdId} Sno={ActorSnoId} Size={MonsterSize} Race={MonsterRace} Quality={MonsterQuality} Type={MonsterType} Affixes={MonsterAffixes} CollisionRadius={CollisionRadius} AxialRadius={AxialRadius} SphereRadius={Radius} RiftValue={RiftValuePct}");
            }
            //else
            //    Core.Logger.Log($"Unit Died: {Name} Acd={AcdId} Sno={ActorSnoId}");

            ActorEvents.FireUnitKilled(this);
        }
        public void HandleEvent(ActorEvents e)
        {
            switch (e)
            {
            case ActorEvents.Started:
                this.actorLogger.ActorStarted();
                this.status = ActorStatus.ReadyToTagDevice;
                break;

            case ActorEvents.DeviceTagged:
                this.actorLogger.DeviceTagged();
                this.status = ActorStatus.WaitingForChanges;
                break;

            case ActorEvents.DeviceTaggingFailed:
                if (this.loopSettings.SchedulableTaggings <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableTaggings--;

                this.failedTwinUpdatesCount++;
                this.actorLogger.DeviceTaggingFailed();
                this.ScheduleDeviceTagging();
                break;

            case ActorEvents.PropertiesUpdated:
                this.actorLogger.DevicePropertiesUpdated();
                this.status = ActorStatus.WaitingForChanges;
                break;

            case ActorEvents.PropertiesUpdateFailed:
                this.failedTwinUpdatesCount++;
                this.actorLogger.DevicePropertiesUpdateFailed();
                this.SchedulePropertiesUpdate(isRetry: true);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(e), e, null);
            }
        }
        public void HandleEvent(ActorEvents e)
        {
            switch (e)
            {
            case ActorEvents.Started:
                if (this.loopSettings.SchedulableFetches <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableFetches--;

                this.actorLogger.ActorStarted();
                this.ScheduleCredentialsSetup();
                break;

            case ActorEvents.FetchFailed:
                if (this.loopSettings.SchedulableFetches <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableFetches--;

                this.failedFetchCount++;
                this.actorLogger.DeviceFetchFailed();
                this.ScheduleFetch();
                break;

            case ActorEvents.DeviceNotFound:
                if (this.loopSettings.SchedulableRegistrations <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableRegistrations--;

                this.actorLogger.DeviceNotFound();
                this.ScheduleRegistration();
                break;

            case ActorEvents.DeviceRegistered:
                this.actorLogger.DeviceRegistered();
                this.ScheduleConnection();
                break;

            case ActorEvents.RegistrationFailed:
                if (this.loopSettings.SchedulableRegistrations <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableRegistrations--;

                this.failedRegistrationsCount++;
                this.actorLogger.DeviceRegistrationFailed();
                this.ScheduleRegistration();
                break;

            case ActorEvents.CredentialsSetupCompleted:
                this.actorLogger.DeviceCredentialsReady();
                this.ScheduleConnection();
                break;

            case ActorEvents.FetchCompleted:
                this.actorLogger.DeviceFetched();
                this.ScheduleConnection();
                break;

            case ActorEvents.AuthFailed:
                this.actorLogger.DeviceConnectionAuthFailed();
                this.ScheduleFetch();
                break;

            case ActorEvents.ConnectionFailed:
                this.failedDeviceConnectionsCount++;
                this.actorLogger.DeviceConnectionFailed();
                this.ScheduleConnection();
                break;

            case ActorEvents.Connected:
                this.actorLogger.DeviceConnected();
                this.status = ActorStatus.Done;
                break;

            case ActorEvents.Disconnected:
                this.actorLogger.DeviceDisconnected();
                // TODO: this works for the time being, but disconnection should not always lead to a deregistration
                //       e.g. there are simulation scenarios where the device might just need to disconnect
                this.ScheduleDeregistration();
                break;

            case ActorEvents.DisconnectionFailed:
                this.actorLogger.DeviceDisconnectionFailed();
                this.ScheduleDisconnection();
                break;

            case ActorEvents.DeviceDeregistered:
                this.actorLogger.DeviceDeregistered();
                this.status = ActorStatus.Deleted;
                break;

            case ActorEvents.DeregisterationFailed:
                this.actorLogger.DeviceDeregistrationFailed();
                this.ScheduleDeregistration();
                break;

            case ActorEvents.TelemetryClientBroken:
                this.Client?.DisconnectAsync();
                this.Client = null;
                this.ScheduleConnection();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(e), e, null);
            }
        }
        public void HandleEvent(ActorEvents e)
        {
            switch (e)
            {
            case ActorEvents.Started:
                if (this.loopSettings.SchedulableFetches <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableFetches--;

                this.actorLogger.ActorStarted();
                this.ScheduleCredentialsSetup();
                break;

            case ActorEvents.FetchFailed:
                if (this.loopSettings.SchedulableFetches <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableFetches--;

                this.failedFetchCount++;
                this.actorLogger.DeviceFetchFailed();
                this.ScheduleFetch();
                break;

            case ActorEvents.DeviceNotFound:
                if (this.loopSettings.SchedulableRegistrations <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableRegistrations--;

                this.actorLogger.DeviceNotFound();
                this.ScheduleRegistration();
                break;

            case ActorEvents.DeviceRegistered:
                this.simulationContext.RateLimiting.DeviceQuotaNotExceeded();
                this.actorLogger.DeviceRegistered();
                this.ScheduleConnection();
                break;

            case ActorEvents.RegistrationFailed:
                if (this.loopSettings.SchedulableRegistrations <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableRegistrations--;

                this.failedRegistrationsCount++;
                this.actorLogger.DeviceRegistrationFailed();
                this.ScheduleRegistration();
                break;

            case ActorEvents.CredentialsSetupCompleted:
                this.actorLogger.DeviceCredentialsReady();
                this.ScheduleConnection();
                break;

            case ActorEvents.FetchCompleted:
                this.actorLogger.DeviceFetched();
                this.ScheduleConnection();
                break;

            case ActorEvents.AuthFailed:
                this.actorLogger.DeviceConnectionAuthFailed();
                this.ScheduleFetch();
                break;

            case ActorEvents.ConnectionFailed:
                this.failedDeviceConnectionsCount++;
                this.actorLogger.DeviceConnectionFailed();
                this.ScheduleConnection();
                break;

            case ActorEvents.Connected:
                this.actorLogger.DeviceConnected();
                this.status = ActorStatus.Done;
                break;

            case ActorEvents.Disconnected:
                this.actorLogger.DeviceDisconnected();
                // TODO: this works for the time being, but disconnection should not always lead to a deregistration
                //       e.g. there are simulation scenarios where the device might just need to disconnect
                this.ScheduleDeregistration();
                break;

            case ActorEvents.DisconnectionFailed:
                this.actorLogger.DeviceDisconnectionFailed();
                this.ScheduleDisconnection();
                break;

            case ActorEvents.DeviceDeregistered:
                this.actorLogger.DeviceDeregistered();
                this.status = ActorStatus.Deleted;
                break;

            case ActorEvents.DeregisterationFailed:
                this.actorLogger.DeviceDeregistrationFailed();
                this.ScheduleDeregistration();
                break;

            case ActorEvents.TelemetryClientBroken:
            case ActorEvents.PropertiesClientBroken:
                // Change the status asap, so the client results disconnected
                // to other actors - see the 'Connected' property - to avoid
                // hub traffic from starting right now
                this.status = ActorStatus.None;
                this.DisposeClient();
                this.ScheduleConnection();
                break;

            case ActorEvents.DeviceQuotaExceeded:
                this.simulationContext.RateLimiting.DeviceQuotaExceeded();
                this.actorLogger.DeviceQuotaExceeded();
                this.PauseForDeviceQuotaExceeded();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(e), e, null);
            }
        }
Example #12
0
        public void HandleEvent(ActorEvents e)
        {
            switch (e)
            {
            case ActorEvents.Started:
                if (this.loopSettings.SchedulableFetches <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableFetches--;

                this.actorLogger.ActorStarted();
                this.ScheduleFetch();
                break;

            case ActorEvents.FetchFailed:
                if (this.loopSettings.SchedulableFetches <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableFetches--;

                this.failedFetchCount++;
                this.actorLogger.DeviceFetchFailed();
                this.ScheduleFetch();
                break;

            case ActorEvents.DeviceNotFound:
                if (this.loopSettings.SchedulableRegistrations <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableRegistrations--;

                this.actorLogger.DeviceNotFound();
                this.ScheduleRegistration();
                break;

            case ActorEvents.DeviceRegistered:
                this.actorLogger.DeviceRegistered();
                this.ScheduleConnection();
                break;

            case ActorEvents.RegistrationFailed:
                if (this.loopSettings.SchedulableRegistrations <= 0)
                {
                    return;
                }
                this.loopSettings.SchedulableRegistrations--;

                this.failedRegistrationsCount++;
                this.actorLogger.DeviceRegistrationFailed();
                this.ScheduleRegistration();
                break;

            case ActorEvents.FetchCompleted:
                this.actorLogger.DeviceFetched();
                this.ScheduleConnection();
                break;

            case ActorEvents.ConnectionFailed:
                this.failedDeviceConnectionsCount++;
                this.actorLogger.DeviceConnectionFailed();
                this.ScheduleConnection();
                break;

            case ActorEvents.Connected:
                this.actorLogger.DeviceConnected();
                this.status = ActorStatus.Done;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(e), e, null);
            }
        }