https://github.com/extrawurst/sockjs-unity3d-xhr-example
usage examples of sockjs-unity3d-xhr lib
https://github.com/extrawurst/sockjs-unity3d-xhr-example
Last synced: about 1 month ago
JSON representation
usage examples of sockjs-unity3d-xhr lib
- Host: GitHub
- URL: https://github.com/extrawurst/sockjs-unity3d-xhr-example
- Owner: extrawurst
- License: mit
- Created: 2014-01-13T12:55:59.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-13T13:20:39.000Z (over 12 years ago)
- Last Synced: 2025-01-25T21:13:12.701Z (over 1 year ago)
- Language: C#
- Size: 176 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
sockjs-unity3d-xhr
==================
sockjs client implementation for unity3D using xhr polling (so this works with unity free license).
just import https://github.com/Extrawurst/sockjs-unity3d-xhr (for example as a submodule) and see the usage example below or the example unity project in this repo.
==================
Usage
==================
For a more complex example see the chat server/client in nodejs and unity in the source code.
See the https://github.com/sockjs/sockjs-node 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
sockjs.Connect("http://localhost:9999/echo/");
}
private void OnMessage(string _msg)
{
// got message
Debug.Log(_msg);
}
private void OnConnect()
{
Debug.Log("connected");
sockjs.SendData("hello world");
}
}
```