SocketIOClient 2.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package SocketIOClient --version 2.0.2                
NuGet\Install-Package SocketIOClient -Version 2.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="SocketIOClient" Version="2.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SocketIOClient --version 2.0.2                
#r "nuget: SocketIOClient, 2.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 SocketIOClient as a Cake Addin
#addin nuget:?package=SocketIOClient&version=2.0.2

// Install SocketIOClient as a Cake Tool
#tool nuget:?package=SocketIOClient&version=2.0.2                

Socket.IO-client for .NET

An elegant socket.io client for .NET

Build Status

How to use

NuGet

Install-Package SocketIOClient

Example of usage

Emit an event

Client:

var client = new SocketIO("http://localhost:11000/");
client.On("hi", response =>
{
    string text = response.GetValue<string>();
});
client.OnConnected += async (sender, e) =>
{
    await client.EmitAsync("hi", ".net core");
};
await client.ConnectAsync();

Server:

socket.on("hi", name => {
    socket.emit("hi", `hi ${name}, You are connected to the server`);
});
Emit with Ack

Client:

var client = new SocketIO("http://localhost:11000/");
client.OnConnected += async (sender, e) =>
{
    await client.EmitAsync("ack", response =>
    {
        result = response.GetValue();
    }, ".net core");
};
await client.ConnectAsync();

Server:

socket.on("ack", (name, fn) => {
    fn({
        result: true,
        message: `ack(${name})`
    });
});
Emit with Binary

Client:

var client = new SocketIO("http://localhost:11000/");
client.OnConnected += async (sender, e) =>
{
    await client.EmitAsync("bytes", name, new
    {
        source = "client001",
        bytes = Encoding.UTF8.GetBytes(".net core")
    });
};

client.On("bytes", response =>
{
    var result = response.GetValue<ByteResponse>();
});

await client.ConnectAsync();
class ByteResponse
{
    public string ClientSource { get; set; }

    public string Source { get; set; }

    [JsonProperty("bytes")]
    public byte[] Buffer { get; set; }
}

Server:

socket.on("bytes", (name, data) => {
    const bytes = Buffer.from(data.bytes.toString() + " - server - " + name, "utf-8");
    socket.emit("bytes", {
        clientSource: data.source,
        source: "server",
        bytes
    });
});
Get multiple response values

Client:

var client = new SocketIO("http://localhost:11000/");
client.OnConnected += async (sender, e) =>
{
    await client.EmitAsync("change", new
    {
        code = 200,
        message = "val1"
    }, "val2");
};
client.On("change", response =>
{
    // You can get the JSON string of the response by calling response.ToString()
    // After that you can decide how to parse the response data.
    // For example: ["val2", { "code": 200, "message": "val1" }]
    string resVal1 = response.GetValue<string>();
    ChangeResponse resVal2 = response.GetValue<ChangeResponse>(1);

    // If you don't want to create a model, you can parse it like this
    string message = response.GetValue(1).Value<string>("message");
    int code = response.GetValue(1).Value<int>("code");

    // More specific usage: https://github.com/jamesnk/newtonsoft.json
});
await client.ConnectAsync();
class ChangeResponse
{
    public int Code { get; set; }
    public string Message { get; set; }
}

Server:

socket.on("change", (val1, val2) => {
    socket.emit("change", val2, val1);
})

More examples

SocketIOClient.Sample
SocketIOClient.Test

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (36)

Showing the top 5 NuGet packages that depend on SocketIOClient:

Package Downloads
ElectronNET.API

Building cross platform electron based desktop apps with .NET Core and ASP.NET Core. This package contains the API to access the "native" electron API.

DigitalRuby.ExchangeSharp

ExchangeSharp is a C# API for working with various cryptocurrency exchanges. Web sockets are also supported for some exchanges.

SocketIOClient.Newtonsoft.Json

socket.io-client json serialization/deserialization for Newtonsoft.Json

Backendless.NET

Backendless is a cloud-based serverless platform which significantly simplifies the process of development of web and mobile applications. This SDK provides the client-side APIs which you can use in your app to take advantage of the Backendless platform functionality. Your application can rely on Backendless for the following functions: Backendless has a ton of awesome functionality including: - Real-time Database - Real-time Publish/Subscribe Messaging - User Management (user registration, login, logout, password recovery) - Push Notification - File operations (upload, download, copy, move, delete) - Geo location All the APIs can be secured with roles-based security. Also, you can create your own API services and deploy them into Backendless.

SecTester.Repeater

This SDK is designed to provide all the basic tools and functions that will allow you to easily integrate the Bright security testing engine into your own project.

GitHub repositories (7)

Showing the top 5 popular GitHub repositories that depend on SocketIOClient:

Repository Stars
ElectronNET/Electron.NET
:electron: Build cross platform desktop apps with ASP.NET Core (Razor Pages, MVC, Blazor).
ArduPilot/MissionPlanner
Mission Planner Ground Control Station for ArduPilot (c# .net)
silahian/VisualHFT
VisualHFT is a cutting-edge GUI platform for market analysis, focusing on real-time visualization of market microstructure. Built with WPF & C#, it displays key metrics like Limit Order Book dynamics and execution quality. Its modular design ensures adaptability for developers and traders, enabling tailored analytical solutions.
DigitalRuby/ExchangeSharp
ExchangeSharp is a powerful, fast and easy to use .NET/C# API for interfacing with many crypto currency exchanges. REST and web sockets are supported.
automuteus/amonguscapture
Capture of the local Among Us executable state
Version Downloads Last updated
3.1.2 7,881 8/18/2024
3.1.1 99,986 9/5/2023
3.1.0 775 8/27/2023
3.0.8 223,097 3/4/2023
3.0.7 31,681 11/29/2022
3.0.7-alpha.3 107 11/29/2022
3.0.7-alpha.2 122 11/29/2022
3.0.7-alpha.1 218 11/6/2022
3.0.6 188,416 3/17/2022
3.0.5 43,894 1/12/2022
3.0.4 25,166 12/6/2021
3.0.4-alpha.1 221 11/18/2021
3.0.3 16,957 9/24/2021
3.0.2 1,197 9/22/2021
3.0.1 521 9/18/2021
3.0.0 2,289 9/13/2021
2.3.1 36,021 8/3/2021
2.3.0 3,350 7/22/2021
2.2.4 32,299 6/24/2021
2.2.3 2,479 6/15/2021
2.2.2 1,481 6/7/2021
2.2.1 1,545 6/5/2021
2.2.1-alpha.1 211 6/4/2021
2.2.0 14,808 4/29/2021
2.1.8-alpha-0 296 4/1/2021
2.1.7 18,795 3/24/2021
2.1.6 3,650 3/11/2021
2.1.5 20,680 2/5/2021
2.1.4 462 2/5/2021 2.1.4 is deprecated because it has critical bugs.
2.1.3 16,034 1/13/2021
2.1.2 1,413 12/23/2020
2.1.1 8,623 11/13/2020
2.1.0 1,149 11/12/2020
2.1.0-alpha.1 316 11/10/2020
2.0.2.9 3,827 10/27/2020
2.0.2.8 780 10/25/2020 2.0.2.8 is deprecated because it has critical bugs.
2.0.2.7 10,880 10/9/2020
2.0.2.6 195,878 9/9/2020
2.0.2.5 1,072 9/8/2020
2.0.2.4 13,174 8/14/2020
2.0.2.3 2,121 7/22/2020
2.0.2.2 1,087 7/11/2020
2.0.2.1 56,906 6/18/2020
2.0.2.1-alpha.2 381 6/16/2020 2.0.2.1-alpha.2 is deprecated because it is no longer maintained.
2.0.2.1-alpha.1 363 6/15/2020 2.0.2.1-alpha.1 is deprecated because it is no longer maintained.
2.0.2 3,607 6/15/2020
2.0.2-alpha.2 367 6/10/2020 2.0.2-alpha.2 is deprecated because it is no longer maintained.
2.0.2-alpha.1 368 6/10/2020 2.0.2-alpha.1 is deprecated because it is no longer maintained.
2.0.1 2,890 6/2/2020
2.0.1-alpha.5 388 6/1/2020 2.0.1-alpha.5 is deprecated because it is no longer maintained.
2.0.1-alpha.4 458 5/30/2020 2.0.1-alpha.4 is deprecated because it is no longer maintained.
2.0.1-alpha.3 372 5/30/2020 2.0.1-alpha.3 is deprecated because it is no longer maintained.
2.0.1-alpha.2 2,416 5/29/2020 2.0.1-alpha.2 is deprecated because it is no longer maintained.
2.0.1-alpha.1 411 5/29/2020 2.0.1-alpha.1 is deprecated because it is no longer maintained.
2.0.0 31,764 5/21/2020
2.0.0-beta.3 391 5/21/2020 2.0.0-beta.3 is deprecated because it is no longer maintained.
2.0.0-beta.2 391 5/21/2020 2.0.0-beta.2 is deprecated because it is no longer maintained.
2.0.0-beta.1 440 5/18/2020 2.0.0-beta.1 is deprecated because it is no longer maintained.
2.0.0-alpha-2 521 5/16/2020 2.0.0-alpha-2 is deprecated because it is no longer maintained.
2.0.0-alpha 452 5/15/2020 2.0.0-alpha is deprecated because it is no longer maintained.
1.0.3.13 3,242 5/8/2020 1.0.3.13 is deprecated because it is no longer maintained.
1.0.3.13-alpha 525 5/7/2020 1.0.3.13-alpha is deprecated because it is no longer maintained.
1.0.3.12 5,516 4/10/2020 1.0.3.12 is deprecated because it is no longer maintained.
1.0.3.11 732 4/9/2020 1.0.3.11 is deprecated because it is no longer maintained.
1.0.3.10 721 4/8/2020 1.0.3.10 is deprecated because it is no longer maintained.
1.0.3.9 961 4/7/2020 1.0.3.9 is deprecated because it is no longer maintained.
1.0.3.8 3,420 3/17/2020 1.0.3.8 is deprecated because it is no longer maintained.
1.0.3.7 738 3/17/2020 1.0.3.7 is deprecated because it is no longer maintained.
1.0.3.6 739 3/16/2020 1.0.3.6 is deprecated because it is no longer maintained.
1.0.3.5 707 3/16/2020 1.0.3.5 is deprecated because it is no longer maintained.
1.0.3.4 673 3/16/2020 1.0.3.4 is deprecated because it is no longer maintained.
1.0.3.3 1,259 3/8/2020 1.0.3.3 is deprecated because it is no longer maintained.
1.0.3.2 687 3/7/2020 1.0.3.2 is deprecated because it is no longer maintained.
1.0.3.1 709 3/7/2020 1.0.3.1 is deprecated because it is no longer maintained.
1.0.3 828 3/2/2020 1.0.3 is deprecated because it is no longer maintained.
1.0.2.7 1,145 2/13/2020 1.0.2.7 is deprecated because it is no longer maintained.
1.0.2.6 2,412 10/21/2019 1.0.2.6 is deprecated because it is no longer maintained.
1.0.2.5 940 9/14/2019 1.0.2.5 is deprecated because it is no longer maintained.
1.0.2.4 771 9/8/2019 1.0.2.4 is deprecated because it is no longer maintained.
1.0.2.3 787 8/27/2019 1.0.2.3 is deprecated because it is no longer maintained.
1.0.2.2 733 8/26/2019 1.0.2.2 is deprecated because it is no longer maintained.
1.0.2.1 757 8/21/2019 1.0.2.1 is deprecated because it is no longer maintained.
1.0.2 770 8/21/2019 1.0.2 is deprecated because it is no longer maintained.
1.0.1 816 8/7/2019 1.0.1 is deprecated because it is no longer maintained.
1.0.0 963 8/6/2019 1.0.0 is deprecated because it is no longer maintained.