An elegant socket.io client for .NET, Supports .NET Standard 2.0
.
Before SocketIOClient v2.2.4, the default EIO is 3, which works with socket.io v2.x, in SocketIOClient v2.2.4, the default EIO is 4, which works with socket.io v3.x and v4.x
SocketIOClient v2.2.0 makes System.Text.Json
the default JSON serializer. If you'd like to continue to use Newtonsoft.Json
, add the SocketIOClient.Newtonsoft.Json NuGet package and set your JsonSerializer to NewtonsoftJsonSerializer on your SocketIO instance. System.Text.Json is faster and uses less memory.
var client = new SocketIO("http://localhost:11000/");
client.JsonSerializer = new NewtonsoftJsonSerializer(client.Options.EIO);
class MyJsonSerializer : SystemTextJsonSerializer
{
public MyJsonSerializer(int eio) : base(eio) {}
public override JsonSerializerOptions CreateOptions()
{
var options = new JsonSerializerOption();
options.PropertyNameCaseInsensitive = true;
return options;
}
}
// ...
var client = new SocketIO("http://localhost:11000/");
client.JsonSerializer = new MyJsonSerializer(client.Options.EIO);
class MyJsonSerializer : NewtonsoftJsonSerializer
{
public MyJsonSerializer(int eio) : base(eio) {}
public override JsonSerializerSettings CreateOptions()
{
return new JsonSerializerSettings
{
ContractResolver = new global::Newtonsoft.Json.Serialization.DefaultContractResolver
{
NamingStrategy = new global::Newtonsoft.Json.Serialization.CamelCaseNamingStrategy()
},
Formatting = Formatting.Indented
};
}
}
// ...
var client = new SocketIO("http://localhost:11000/");
client.JsonSerializer = new MyJsonSerializer(client.Options.EIO);
Before development or testing, you need to install the nodejs.
# start socket.io v2 server
cd src/socket.io-server-v2
npm i # If the dependencies are already installed, you can ignore this step.
npm start
# start socket.io v3 server
cd src/socket.io-server-v3
npm i # If the dependencies are already installed, you can ignore this step.
npm start
- gcoverd, 250 AUD
- darrachequesne (socket.io team), 500 USD, April 2021
- darrachequesne (socket.io team), 500 USD, May 2021