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); }
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); }
public StreamDeckPluginManager(IStreamDeckConnection streamDeckConnection) { this.streamDeckConnection = streamDeckConnection; streamDeckConnection.Listen <DidReceiveGlobalSettingsEvent>(s => { this.CurrentSettings = s.Settings.Settings; return(Task.CompletedTask); }); }
public IDisposable OnSettingChange(Action <JObject> action) => streamDeckConnection.Listen <DidReceiveGlobalSettingsEvent>(s => { action(s.Settings.Settings); return(Task.CompletedTask); });