Home

Awesome

socket.io-unity

unity-nodejs

Socket.IO Client Library for Unity (mono / .NET 2.0), which is ported from the JavaScript client version 1.1.0.

SocketIoClientDotNet by Quobject is a very good project, but it does not support Unity. So I spent a few overnights to port it to mono/.NET 2.0.

Now game developers can:

Installation

Downlaod socket.io.unitypackage and then import into Unity.

Or, only download the following files in Lib and put to Unity project:

It's available on Unity Asset Store for $10, but you can also download it for FREE here.

If you are interested to dig into the source code, welcome to fork the SocketIoClientDotNet for .NET 2.0.

Usage

socket.io client for Unity has a similar api to those of the JavaScript client.

using Quobject.SocketIoClientDotNet.Client;

var socket = IO.Socket("http://localhost:3000");
socket.On(Socket.EVENT_CONNECT, () =>
{
  socket.Emit("hi");
});
socket.On("hi", (data) =>
{
  Debug.Log(data);
  socket.Disconnect();
});

And, with Newtonsoft.Json.dll, we can easliy serialize / deserialize json object. Read more about Newtonsoft.Json.

Features

This library supports all of the features the JS client does, including events, options and upgrading transport.

Framework Versions

Mono, .NET 2.0

Demo

Comparison

ProjectAuthorPopularityStatus
socket.io-unityfloatinghotpotnewACTIVE, support .NET 2.0 and Unity
SocketIoClientDotNetQuobject323 starsACTIVE, support .NET 3.5 and higher, but not compatible with .NET 2.0 and Unity
UnitySocketIONetEase547 starsno longer maintained, not compatible with socket.io 1.x and later
unity-socket.io-DEPRECATEDfpanettieri189 starsno longer maintained
UnitySocketIO-WebSocketSharpkaistseo108 starsno longer maintained

Credit

Thanks to the authors of following projects: