Sockjs Unity3d Xhr Example

by Extrawurst

usage examples of sockjs-unity3d-xhr lib

( Updated an hour ago )


sockjs client implementation for unity3D using xhr polling (so this works with unity free license). just import (for example as a submodule) and see the usage example below or the example unity project in this repo.



For a more complex example see the chat server/client in nodejs and unity in the source code. See the sockjs documentation for details on the server implementation.

Simple usage example:

public class Client : MonoBehaviour {

    public SockjsClient sockjs = new SockjsClient();

    public void Start()
        sockjs.OnMessage += OnMessage;
        sockjs.OnConnect += OnConnect;

        // connect to wherever your server is running

    private void OnMessage(string _msg)
        // got message

    private void OnConnect()

        sockjs.SendData("hello world");