Coder Social home page Coder Social logo

buccia85 / socket.io-client-csharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from doghappy/socket.io-client-csharp

0.0 0.0 0.0 2.87 MB

socket.io-client implemention for .NET

License: MIT License

C# 86.94% Dockerfile 0.14% HTML 2.34% CSS 0.59% JavaScript 9.98% PowerShell 0.02%

socket.io-client-csharp's Introduction

Socket.IO-client for .NET

An elegant socket.io client for .NET, Supports .NET Standard 2.0.

Build Status NuGet

How to use

Wiki

Breaking changes in 2.2.4

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

Breaking changes in 2.2.0

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.

Continue to use Newtonsoft.Json

var client = new SocketIO("http://localhost:11000/");
client.JsonSerializer = new NewtonsoftJsonSerializer(client.Options.EIO);

Custom JsonSerializerOptions/System.Text.Json

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);

Custom JsonSerializerSettings/Newtonsoft.Json

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);

Development

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

Change log

SocketIOClient

Sponsors

socket.io-client-csharp's People

Contributors

doghappy avatar futuristicoder avatar dependabot[bot] avatar yujianghao avatar 23w avatar crackxia avatar swuttich avatar muscla87 avatar bitcoinbrisbane avatar giraffesyo avatar stfkolev avatar jlareo avatar tearth avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.