Example #1
0
        public void Run(StreamDeckOptions options)
        {
            pluginUUID = options.PluginUUID;
            deviceInfo = options.DeviceInfo;
            connection = new StreamDeckConnection(options.Port, options.PluginUUID, options.RegisterEvent);

            // Register for events
            connection.OnConnected     += Connection_OnConnected;
            connection.OnDisconnected  += Connection_OnDisconnected;
            connection.OnKeyDown       += Connection_OnKeyDown;
            connection.OnKeyUp         += Connection_OnKeyUp;
            connection.OnWillAppear    += Connection_OnWillAppear;
            connection.OnWillDisappear += Connection_OnWillDisappear;

            // Settings changed
            connection.OnDidReceiveSettings       += Connection_OnDidReceiveSettings;
            connection.OnDidReceiveGlobalSettings += Connection_OnDidReceiveGlobalSettings;

            // Start the connection
            connection.Run();
            Logger.Instance.LogMessage(TracingLevel.INFO, "Connecting to Stream Deck");

            // Wait for up to 10 seconds to connect
            if (connectEvent.WaitOne(TimeSpan.FromSeconds(10)))
            {
                Logger.Instance.LogMessage(TracingLevel.INFO, "Connected to Stream Deck");

                // We connected, loop every second until we disconnect
                while (!disconnectEvent.WaitOne(TimeSpan.FromMilliseconds(1000)))
                {
                    RunTick();
                }
            }
            Logger.Instance.LogMessage(TracingLevel.INFO, "Plugin Disconnected - Exiting");
        }
 private static void RunPlugin(StreamDeckOptions options, PluginActionId[] supportedActionIds)
 {
     container = new PluginContainer(supportedActionIds);
     container.Run(options);
 }