Пример #1
0
        protected override async Task OnStarted(Proto.IContext context)
        {
            await base.OnStarted(context);

            Subscribe <TcpCommand>();
            Subscribe <TcpQuery, string>(true);
        }
Пример #2
0
        protected override async Task OnStarted(Proto.IContext context)
        {
            await base.OnStarted(context).ConfigureAwait(false);

            _serialDevice.Init();
            _disposeContainer.Add(_serialDevice.Subscribe(Handle));
            _disposeContainer.Add(_serialDevice);
        }
Пример #3
0
        protected override async Task OnStarted(Proto.IContext context)
        {
            await base.OnStarted(context).ConfigureAwait(false);

            ReadConfigurationFromProperties();
            var areas = ReadAreasFromAttachedProperties();

            ReadRoomsFromAttachedProperties(areas);

            StartWatchForEvents();
        }
    protected async override Task ReceiveAsyncInternal(Proto.IContext context)
    {
        if (await HandleSystemMessages(context))
        {
            return;
        }
        var msg = FormatMessage(context.Message);

        if (msg is HomeCenter.Model.Messages.ActorMessage ic)
        {
            ic.Context = context;
        }

        ;
        if (msg is CapabilitiesQuery query_0)
        {
            var result = Handle(query_0);
            context.Respond(result);
            return;
        }
        else if (msg is SupportedStatesQuery query_1)
        {
            var result = Handle(query_1);
            context.Respond(result);
            return;
        }
        else if (msg is StateQuery query_2)
        {
            var result = Handle(query_2);
            context.Respond(result);
            return;
        }

        if (msg is SystemStartedEvent event_0)
        {
            await OnSystemStarted(event_0).ConfigureAwait(false);

            return;
        }
        else if (msg is Event event_1)
        {
            await Handle(event_1).ConfigureAwait(false);

            return;
        }
        else if (msg is SystemStartedEvent event_2)
        {
            await OnSystemStarted(event_2).ConfigureAwait(false);

            return;
        }

        await UnhandledMessage(msg);
    }
Пример #5
0
        protected async override Task ReceiveAsyncInternal(Proto.IContext context)
        {
            if (await HandleSystemMessages(context))
            {
                return;
            }
            var msg = FormatMessage(context.Message);

            if (msg is ActorMessage ic)
            {
                ic.Context = context;
            }

            if (msg is CapabilitiesQuery query_0)
            {
                var result = await Handle(query_0);

                context.Respond(result);
                return;
            }
            else if (msg is SupportedStatesQuery query_1)
            {
                var result = HandleSupportedState(query_1);
                context.Respond(result);
                return;
            }
            else if (msg is StateQuery query_2)
            {
                var result = await HandleState(query_2);

                context.Respond(result);
                return;
            }
            else if (msg is TcpQuery query_3)
            {
                var result = await Handle(query_3);

                context.Respond(result);
                return;
            }
            if (msg is AdjustPowerLevelCommand command_0)
            {
                await HandleState(command_0);

                return;
            }
            else if (msg is ModeSetCommand command_1)
            {
                HandleState(command_1);
                return;
            }
            else if (msg is TcpCommand command_2)
            {
                await Handle(command_2);

                return;
            }
            if (msg is SystemStartedEvent event_0)
            {
                await OnSystemStarted(event_0);

                return;
            }
            else if (msg is MotionEvent event_1)
            {
                OnMotion(event_1);
                return;
            }
            await UnhandledMessage(msg);
        }
Пример #6
0
 public Context(Proto.IContext impl)
 {
     _impl = impl;
 }