示例#1
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            // this listens and orchastrate communication from a streamdesk connection (be it inmemory or remote)

            await streamDeckConnection.Connect();

            this.appearListener = streamDeckConnection.Listen <WillAppearEvent>(StartAction);

            this.disappearListener = streamDeckConnection.Listen <WillDisappearEvent>(StopAction);
        }
示例#2
0
        public async Task Initialize(ActionDefinition actionDefinition, StreamDeckInboundActionEvent triggeringEvent)
        {
            if (this.ContextId != null || this.ActionDefinition != null)
            {
                throw new InvalidOperationException($"{nameof(Initialize)} may only be called once");
            }

            this.ContextId        = triggeringEvent.Context;
            this.ActionDefinition = actionDefinition;

            this.listener = connection.Listen <StreamDeck.Events.StreamDeckInboundActionEvent>(e =>
            {
                if (e.Context == this.ContextId && e.Action.Equals(this.ActionDefinition.UUID, StringComparison.OrdinalIgnoreCase))
                {
                    return(ProcessEventsAsync(e));
                }

                return(Task.CompletedTask);
            });

            var handler = serviceProvider.GetRequiredService(this.ActionDefinition.Handler);

            Bind(handler);

            await ProcessEventsAsync(triggeringEvent);
        }
示例#3
0
        public StreamDeckPluginManager(IStreamDeckConnection streamDeckConnection)
        {
            this.streamDeckConnection = streamDeckConnection;

            streamDeckConnection.Listen <DidReceiveGlobalSettingsEvent>(s =>
            {
                this.CurrentSettings = s.Settings.Settings;
                return(Task.CompletedTask);
            });
        }
示例#4
0
 public IDisposable OnSettingChange(Action <JObject> action) =>
 streamDeckConnection.Listen <DidReceiveGlobalSettingsEvent>(s =>
 {
     action(s.Settings.Settings);
     return(Task.CompletedTask);
 });