MiniTwitch.PubSub
1.0.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package MiniTwitch.PubSub --version 1.0.2
NuGet\Install-Package MiniTwitch.PubSub -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MiniTwitch.PubSub" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MiniTwitch.PubSub --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MiniTwitch.PubSub, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MiniTwitch.PubSub as a Cake Addin
#addin nuget:?package=MiniTwitch.PubSub&version=1.0.2
// Install MiniTwitch.PubSub as a Cake Tool
#tool nuget:?package=MiniTwitch.PubSub&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MiniTwitch.PubSub
MiniTwitch.PubSub is the component responsible for interaction with the Twitch PubSub service. The usage of this package revolves around the PubSubClient
class and the Topics
static class.
Features
- Package code is fully documented with XML comments
- Exposes documented & undocumented PubSub topics
- Uses
System.Text.Json
under the hood; Fast, efficient and without unnecessary dependencies - Exposes events with
Func<T1, .., ValueTask>
delegates, making asynchronous handling very easy - Automatically reconnects upon disconnection & automatically re-listens to topics
- Simplistic; Events have clear descriptions on what they do and how to get them invoked
- Multi-token support; You're not limited to 1 auth token per
PubSubClient
- Comes with a built-in logger, which can be disabled or replaced easily
- Events return the topic parameters as
ChannelId
orUserId
, making them easily distinguishable
Getting Started
here is an example usage of the PubSubClient
class:
using MiniTwitch.PubSub;
using MiniTwitch.PubSub.Interfaces;
using MiniTwitch.PubSub.Models;
using MiniTwitch.PubSub.Payloads;
namespace MiniTwitchExample;
public class Program
{
static async Task Main()
{
PubSubClient client = new("my token");
await client.ConnectAsync();
var playbackResponse = await client.ListenTo(Topics.VideoPlayback(36175310));
if (playbackResponse.IsSuccess)
Console.WriteLine($"Listened to {playbackResponse.TopicKey} successfully!");
var responses = await client.ListenTo(Topics.Following(783267696) | Topics.ChatroomsUser(754250938, "a different token"));
foreach (var response in responses)
{
if (!response.IsSuccess)
Console.WriteLine($"Failed to listen to {response.TopicKey}! Error: {response.Error}");
}
client.OnStreamUp += OnStreamUp;
client.OnFollow += OnFollow;
client.OnTimedOut += OnTimedOut;
_ = Console.ReadLine();
}
private static ValueTask OnStreamUp(ChannelId channelId, IStreamUp stream)
{
Console.WriteLine($"Channel ID {channelId} just went live! (Stream delay: {stream.PlayDelay})");
return ValueTask.CompletedTask;
}
private static ValueTask OnFollow(ChannelId channelId, Follower follower)
{
Console.WriteLine($"{follower.Name} just followed you!");
return ValueTask.CompletedTask;
}
private static ValueTask OnTimedOut(UserId userId, ITimeOutData timeout)
{
Console.WriteLine(
$"Your other account (ID: {userId}) has been timed out for {timeout.ExpiresInMs}ms in channel ID {timeout.ChannelId}");
return ValueTask.CompletedTask;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 is compatible. 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- MiniTwitch.Common (>= 1.1.4)
-
net7.0
- MiniTwitch.Common (>= 1.1.4)
-
net8.0
- MiniTwitch.Common (>= 1.1.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.