LumiaSdk 0.0.7
dotnet add package LumiaSdk --version 0.0.7
NuGet\Install-Package LumiaSdk -Version 0.0.7
<PackageReference Include="LumiaSdk" Version="0.0.7" />
paket add LumiaSdk --version 0.0.7
#r "nuget: LumiaSdk, 0.0.7"
// Install LumiaSdk as a Cake Addin #addin nuget:?package=LumiaSdk&version=0.0.7 // Install LumiaSdk as a Cake Tool #tool nuget:?package=LumiaSdk&version=0.0.7
The official Lumia Stream SDK for C#
This repository is for the Lumia Stream SDK releases and documentation.
Developers can use the Lumia Stream SDK to extend and control the Lumia Stream desktop app, enabling them to control smart lights, MIDI, DMX, OSC, OBS, TTS and so much more to create a custom and unique lighting experience.
Table of Contents
Installation
Self Build
You should add your LumiaSdk.dll (e.g. /path/to/LumiaSdk/bin/Debug/netcoreapp3.1/LumiaSdk.dll
) to the library references of your project.
If you would like to use that dll in your [Unity] project, you should add it to any folder of your project (e.g. Assets/Plugins
) in the Unity Editor.
NuGet Gallery
LumiaSdk is available on the NuGet Gallery, as a prerelease version.
- [NuGet Gallery: LumiaSdk]
You can add LumiaSdk to your project with the NuGet Package Manager, by using the following command in the Package Manager Console.
PM> Install-Package LumiaSdk -Pre
Run the SDK
We've also included an example for using the SDK.
To run the example head to examples and you will see the Progam.cs
file there.
Make sure you replace your token with the token that you will find in Lumia Stream's settings. Or if you're making a game, you should use the Game Token that you can create from here Here is how to find your API token
After you have your token and replaced it inside of the Progam.cs
, you can now run the Program:
This will first initialize the sdk to create the connection. Then it will listen in on events that are coming through.
Sample
The following snippet shows a valid sdk example
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Threading.Tasks;
using Lumia;
namespace Examples
{
class Program
{
private static string token = ""; // Game token that you have retrieved from https://lumiastream.com/games/submit
private static string name = ""; // Name of the game that will be prompted for the user to approve
public static async Task testSends(LumiaSdk lumia)
{
// Sending a command; with a callback to get the result for this call
await lumia.SendCommand("red", null, null);
RGB rgb = new RGB();
rgb.r = 255;
rgb.g = 0;
rgb.b = 255;
await lumia.SendColor(rgb, 60, 1000);
// Sending a brightness
await lumia.SendBrightness(100);
// Sending a TTS message
await lumia.SendTts("This SDK is the best");
// Sending a Chat bot message
await lumia.SendChatbot(Platforms.TWITCH, "This SDK is the best");
}
public static async Task run()
{
LumiaSdk lumia = new LumiaSdk();
await lumia.init(token, name);
lumia.error += (string r) =>
{};
lumia.closed += (string r) =>
{};
lumia.events += (JObject data) =>
{
// here we give the context as we know it's an SDK Eent types
switch (LumiaUtils.getTypeValueFromString<LumiaEventTypes>("LumiaEventTypes", data["type"].Value<string>()))
{
case LumiaEventTypes.STATES:
break;
case LumiaEventTypes.COMMAND:
break;
case LumiaEventTypes.CHAT:
break;
case LumiaEventTypes.ALERT:
break;
}
};
var r = await lumia.GetInfo();
await testSends(lumia);
}
public static void Main(string[] args)
{
run().GetAwaiter().GetResult();
}
}
}
Events
Events are broadcasted by Lumia Stream to each connected client when an action occurs inside Lumia Stream.
These events range from the app state being changed, raw chat messages, chat commands, alerts and much more.
An event message will contain at least the following base fields:
type
LumiaEventTypes: the type of event.origin
EventOrigins (optional): where the event originated from. i.e: twitch for exampledata
ILumiaEventStateBody | ILumiaEventChatCommandBody | ILumiaEventChatBody | ILumiaEventAlertBody | ILumiaEventStateBody (optional): the body of the event
Additional fields may be present in the event message depending on the event type.
States
States indicate the current status the Lumia Stream is in
Example Response:
{
"origin": null,
"type": "states",
"data": { "on": 1, "streamMode": 1, "fuze": 0 }
}
Chat Command
Lumia Stream has been prompted to trigger a command
Example Response:
{
"origin": "twitch",
"type": "command",
"data": { "username": "lumiastream", "command": "red" },
"raw": { "username": "lumiastream", "command": "red" }
}
Chat
A raw chat message that has been sent
Example Response (From Twitch):
{
"type": "chat",
"data": {
"channel": "#lumiastream",
"message": "Wow",
"username": "lumiastream",
"userId": "163366031",
"userColor": "#8A2BE2",
"userColorRgb": "138,43,226",
"platform": "twitch",
"badgesRaw": "broadcaster/1,subscriber/0",
"hasEmotes": false,
"emotes": "",
"rawMessageWithoutEmotes": "Wow",
"emotesRaw": "",
"user": {
"badge-info": [],
"badges": [],
"client-nonce": "",
"color": "#8A2BE2",
"display-name": "lumiastream",
"emotes": null,
"first-msg": false,
"flags": null,
"id": "188ebc3d-e6e2-4b36-a125-0c4f0c0f54fd",
"mod": false,
"room-id": "163366031",
"subscriber": true,
"turbo": false,
"user-id": "163366031",
"user-type": null,
"emotes-raw": null,
"badge-info-raw": "subscriber/21",
"badges-raw": "broadcaster/1,subscriber/0",
"username": "lumiastream",
"message-type": "chat",
"isSelf": false,
"vip": false,
"tier3": true,
"tier2": true,
"tier1": true,
"follower": false
}
}
}
Alert
A raw alert has been sent
Example Response (From Twitch Follow):
{
"origin": "twitch",
"type": "alert",
"event": "twitch-follower",
"data": { "userId": "12345", "username": "lumiastream" },
"raw": { "userId": "12345", "username": "lumiastream" }
}
Control
You can control Lumia Stream as well through the SDK in a variety of ways.
You will have the ability to send a command, an alert, a chat bot message, tts, a direct color, as well as even triggering certain lights.
Get Settings
There are a few reasons why you may want to receive settings from Lumia Stream. These settings will include all of the lights that are connected to Lumia, the current state of the app, whether the user is premium or not and more
Example:
const info = await sdk.GetInfo();
Send Command
The simplest way to use Lumia is first setting up a command inside of Lumia Stream and then recalling it with the SDK
Example:
await lumia.SendCommand("red", null, null);
Send Color
Sending a color gives you the ability to set your lights to whatever color you choose along with the brightness and the duration. The duration is so that Lumia can revert back to defaul after the determined time
Example:
RGB rgb = new RGB();
rgb.r = 255;
rgb.g = 0;
rgb.b = 255;
await lumia.SendColor(rgb, 60, 1000);
Using the same sendColor method you can also choose which lights receive the color change
Example:
RGB rgb = new RGB();
rgb.r = 255;
rgb.g = 0;
rgb.b = 255;
List lights;
await lumia.SendColor(rgb, 60, 1000, null, null, null, lights);
Send Brightness
Sending brightness alone will keep all of your lights at their current state while only updating the brightness value
Example:
await lumia.SendBrightness(100);
Send TTS
Sending TTS messages will give you the ability to use Lumia's TTS by just caling the sendTts method
Example:
await lumia.SendTts("This SDK is the best");
Send Chat bot
Sending a Chat bot messages will allow you to send messages to chat through Lumia's Chat bot
Example:
await lumia.SendChatbot(Platforms.TWITCH, "This SDK is the best");
Send Chat Command
Lumia Stream has been prompted to trigger a command
Example Response:
{
"origin": "twitch",
"type": "command",
"data": { "username": "lumiastream", "command": "red" },
"raw": { "username": "lumiastream", "command": "red" }
}
Send Chat
A raw chat message that has been sent
Example Response (From Twitch):
{
"type": "chat",
"data": {
"channel": "#lumiastream",
"message": "Wow",
"username": "lumiastream",
"userId": "163366031",
"userColor": "#8A2BE2",
"userColorRgb": "138,43,226",
"platform": "twitch",
"badgesRaw": "broadcaster/1,subscriber/0",
"hasEmotes": false,
"emotes": "",
"rawMessageWithoutEmotes": "Wow",
"emotesRaw": "",
"user": {
"badge-info": [],
"badges": [],
"client-nonce": "",
"color": "#8A2BE2",
"display-name": "lumiastream",
"emotes": null,
"first-msg": false,
"flags": null,
"id": "188ebc3d-e6e2-4b36-a125-0c4f0c0f54fd",
"mod": false,
"room-id": "163366031",
"subscriber": true,
"turbo": false,
"user-id": "163366031",
"user-type": null,
"emotes-raw": null,
"badge-info-raw": "subscriber/21",
"badges-raw": "broadcaster/1,subscriber/0",
"username": "lumiastream",
"message-type": "chat",
"isSelf": false,
"vip": false,
"tier3": true,
"tier2": true,
"tier1": true,
"follower": false
}
}
}
Send Alert
Send a mock alert
Example:
await sdk.SendAlert({ alert: LumiaAlertValues.TWITCH_FOLLOWER });
Resources
- Download the latest Lumia Stream SDK release from nuget
- Read the full API reference
- Browse some examples
Let's link
Reach out to us on Discord to show off what you're working on, or to just lounge around and speak about ideas Link
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.1)
- WebSocketSharp.Standard (>= 1.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
### Features
* Added SendHexColor method to send a color with a regular string
* Added defaults to parameters that aren't necessary for the sdk
* Added ability to use the SDK with various Deck devices