H.WebSockets
1.2.7
See the version list below for details.
dotnet add package H.WebSockets --version 1.2.7
NuGet\Install-Package H.WebSockets -Version 1.2.7
<PackageReference Include="H.WebSockets" Version="1.2.7" />
paket add H.WebSockets --version 1.2.7
#r "nuget: H.WebSockets, 1.2.7"
// Install H.WebSockets as a Cake Addin #addin nuget:?package=H.WebSockets&version=1.2.7 // Install H.WebSockets as a Cake Tool #tool nuget:?package=H.WebSockets&version=1.2.7
H.Socket.IO
High-performance event-based .NET Socket.IO library with a convenient interface,
aimed at writing the smallest possible code on the user side.
Features:
- Supports the latest version of Socket.IO server
- Supports namespaces
- The library is null-free and does not contain NRE
- Event-based
- Completely asynchronous
Nuget
Install-Package H.Socket.IO
Usage
using System;
using System.Threading.Tasks;
using H.Socket.IO;
#nullable enable
public class ChatMessage
{
public string? Username { get; set; }
public string? Message { get; set; }
public long NumUsers { get; set; }
}
public async Task ConnectToChatNowShTest()
{
await using var client = new SocketIoClient();
client.Connected += (sender, args) => Console.WriteLine($"Connected: {args.Namespace}");
client.Disconnected += (sender, args) => Console.WriteLine($"Disconnected. Reason: {args.Reason}, Status: {args.Status:G}");
client.EventReceived += (sender, args) => Console.WriteLine($"EventReceived: Namespace: {args.Namespace}, Value: {args.Value}, IsHandled: {args.IsHandled}");
client.HandledEventReceived += (sender, args) => Console.WriteLine($"HandledEventReceived: Namespace: {args.Namespace}, Value: {args.Value}");
client.UnhandledEventReceived += (sender, args) => Console.WriteLine($"UnhandledEventReceived: Namespace: {args.Namespace}, Value: {args.Value}");
client.ErrorReceived += (sender, args) => Console.WriteLine($"ErrorReceived: Namespace: {args.Namespace}, Value: {args.Value}");
client.ExceptionOccurred += (sender, args) => Console.WriteLine($"ExceptionOccurred: {args.Value}");
client.On("login", () =>
{
Console.WriteLine("You are logged in.");
});
client.On("login", json =>
{
Console.WriteLine($"You are logged in. Json: \"{json}\"");
});
client.On<ChatMessage>("login", message =>
{
Console.WriteLine($"You are logged in. Total number of users: {message.NumUsers}");
});
client.On<ChatMessage>("user joined", message =>
{
Console.WriteLine($"User joined: {message.Username}. Total number of users: {message.NumUsers}");
});
client.On<ChatMessage>("user left", message =>
{
Console.WriteLine($"User left: {message.Username}. Total number of users: {message.NumUsers}");
});
client.On<ChatMessage>("typing", message =>
{
Console.WriteLine($"User typing: {message.Username}");
});
client.On<ChatMessage>("stop typing", message =>
{
Console.WriteLine($"User stop typing: {message.Username}");
});
client.On<ChatMessage>("new message", message =>
{
Console.WriteLine($"New message from user \"{message.Username}\": {message.Message}");
});
await client.ConnectAsync(new Uri("wss://socketio-chat-h9jt.herokuapp.com/"));
await client.Emit("add user", "C# H.Socket.IO Test User");
await Task.Delay(TimeSpan.FromMilliseconds(200));
await client.Emit("typing");
await Task.Delay(TimeSpan.FromMilliseconds(200));
await client.Emit("new message", "hello");
await Task.Delay(TimeSpan.FromMilliseconds(200));
await client.Emit("stop typing");
await Task.Delay(TimeSpan.FromSeconds(2));
await client.DisconnectAsync();
}
Namespaces
// Will be sent with all messages(Unless otherwise stated).
// Also automatically connects to it.
client.DefaultNamespace = "my";
// or
// Connects to "my" namespace.
await client.ConnectAsync(new Uri(LocalCharServerUrl), namespaces: "my");
// Sends message to "my" namespace.
await client.Emit("message", "hello", "my");
Custom arguments
await client.ConnectAsync(new Uri($"wss://socketio-chat-h9jt.herokuapp.com/?access_token={mAccessToken}"));
Live Example
C# .NET Fiddle - https://dotnetfiddle.net/FWMpQ3
VB.NET .NET Fiddle - https://dotnetfiddle.net/WzIdnG
Http client of the tested Socket.IO server - https://socket-io-chat.now.sh/
Used documentation
Socket.IO Protocol - https://github.com/socketio/socket.io-protocol
Engine.IO Protocol - https://github.com/socketio/engine.io-protocol
Python implementation of Socket.IO - https://github.com/miguelgrinberg/python-socketio/blob/master/socketio/
Python implementation of Engine.IO - https://github.com/miguelgrinberg/python-engineio/blob/master/engineio/
Contacts
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 is compatible. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. 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. |
-
.NETFramework 4.5
- System.ValueTuple (>= 4.5.0)
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on H.WebSockets:
Package | Downloads |
---|---|
H.Engine.IO
Features: - Very simple use in several lines - all the code for obtaining the data is already written and working in a background thread - It's event based class - available TextMessageReceived and BinaryMessageReceived events - Also available Connected, Disconnected and ExceptionOccurred events - Right async methods that support CancellationToken's - Auto Reconnect - Open to suggestions and problems on the github |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on H.WebSockets:
Repository | Stars |
---|---|
SaviorXTanren/mixer-mixitup
Streaming bot application for handling chat, events, moderation, and other streamer assistance features
|
Version | Downloads | Last updated |
---|---|---|
1.2.16 | 3,495 | 8/29/2023 |
1.2.15 | 737 | 7/8/2023 |
1.2.14 | 306 | 7/8/2023 |
1.2.13 | 283 | 7/8/2023 |
1.2.11 | 18,894 | 1/4/2023 |
1.2.10 | 4,484 | 8/1/2022 |
1.2.9 | 2,240 | 3/19/2022 |
1.2.7 | 2,047 | 10/23/2021 |
1.2.6 | 620 | 10/21/2021 |
1.2.5 | 549 | 10/21/2021 |
1.2.4 | 562 | 10/21/2021 |
1.2.3 | 566 | 10/21/2021 |
1.2.1 | 1,579 | 7/15/2021 |
1.1.7.1 | 1,674 | 5/7/2021 |
1.1.7 | 32,106 | 1/11/2021 |
1.1.6 | 643 | 1/9/2021 |
1.1.5 | 622 | 1/9/2021 |
1.1.4 | 3,162 | 1/8/2021 |
1.1.3 | 660 | 1/4/2021 |
1.1.2 | 1,260 | 12/17/2020 |
1.1.1 | 4,023 | 12/9/2020 |
1.1.0 | 1,425 | 11/22/2020 |
1.0.13 | 7,352 | 6/5/2020 |
1.0.12 | 836 | 6/3/2020 |
1.0.11 | 774 | 6/3/2020 |
1.0.10 | 1,598 | 5/21/2020 |
1.0.9 | 800 | 5/21/2020 |
1.0.8 | 786 | 5/21/2020 |
1.0.7 | 782 | 5/21/2020 |
1.0.6 | 891 | 4/21/2020 |
1.0.5 | 713 | 4/21/2020 |
1.0.4 | 843 | 2/3/2020 |
1.0.3 | 779 | 2/2/2020 |
1.0.2 | 815 | 1/29/2020 |
1.0.1 | 830 | 1/29/2020 |
1.0.0 | 13,719 | 1/9/2020 |
⭐ Last 10 features:
- feat: To net6.0 and C# 10. 2021-10-21
- feat: Updated Newtonsoft.Json to 13.0.1. 2021-07-16
🐞 Last 10 bug fixes:
- fix: Fixed </br> in README. 2021-10-21
- fix: Fixed LocalTests. 2021-10-21
- fix: Fixed PackageReadmeFile. 2021-10-21