Skip to content

A minimalistic c# implementation of socket.io that supports the minimal requirements

License

Notifications You must be signed in to change notification settings

it9gamelog/socketio-with-ws-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Name

socketio-with-ws-client - A simplified, bare minimum C# socket.io client implementation

This version only support Engine IO v4 and websocket mode. For Engine IO v3, please checkout the "eio3" release.

Synopsis

var c = new SocketIoWithWsClient();
c.IncomingEvent += (sender, e) => {
  Console.WriteLine(e.payload);
};
c.Ping += (sender, e) => {
  Console.WriteLine("Ping");
};
c.Disconnect += (sender, e) => {
  Console.WriteLine("Disconnected");
};

// For making TLS v1.2 connection which is used by HTTPS
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

await c.ConnectAsync(new Uri("https://example.com/?custom=query_string"));
c.SendEventPayload("[\"Sample EventName\",\"\\\"The quick brown fox jumps over the lazy dog\\\"\"]");

Usage

  • Requires Newtonsoft.Json. Tested on .NET v4.5.2.
  • Copy the file and use it as is. No NuGet package. Modify if needed.
  • Only support upgrade to websocket protocol.

Limitation

  • Only socket.io Event is supported. Ack, Error, Binary_Event, Binary_Ack are ignored.
    Implement them in ReceiverLoop() if needed.

Background Story

See https://medium.com/@it9gamelog/socket-io-a-c-client-library-be9bdc1eb6ab

About

A minimalistic c# implementation of socket.io that supports the minimal requirements

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages