unity sockets io code example
Example: unity socket io
// Use this library, it works perfectly:
// https://github.com/dp0ch/Unity-SocketIO-Client
// Usage:
using Dpoch.SocketIO;
public class MyClass : MonoBehavior {
public void Start {
var socket = new SocketIO("ws://127.0.0.1:80/socket.io/?EIO=4&transport=websocket");
socket.OnOpen += () => {
Debug.Log("Connected!")
};
socket.OnConnectFailed += () => {
Debug.Log("Connection failed.")
};
socket.OnClose += () => {
Debug.Log("Connection closed.")
};
socket.OnError += (err) => {
Debug.Log("Error: " + err)
};
socket.Connect();
}
}
// Look into the libararies README for further documentation.