All-in-One Solution for Indie Game Development · Empowering Indie Developers' Dreams
Documentation · Quick Start · QQ Group: 467608841 / 233840761
English | 简体中文 | 繁體中文 | 日本語 | 한국어
WebSocket library for Unity. This library primarily serves as a sub-library for https://github.com/AlianBlank/GameFrameX.
Choose one of the following methods:
-
Edit your Unity project's
Packages/manifest.jsonand add thescopedRegistriessection:{ "scopedRegistries": [ { "name": "GameFrameX", "url": "https://gameframex.upm.alianblank.uk", "scopes": [ "com.gameframex" ] } ], "dependencies": { "com.gameframex.unity.psygames.unitywebsocket": "2.9.2" } }scopescontrols which packages are resolved through this registry. Only packages whose names start withcom.gameframexwill be fetched from it. -
Add to
manifest.jsondependencies:{ "com.gameframex.unity.psygames.unitywebsocket": "https://github.com/gameframex/com.gameframex.unity.psygames.unitywebsocket.git" } -
Use Package Manager in Unity with Git URL:
https://github.com/gameframex/com.gameframex.unity.psygames.unitywebsocket.git -
Clone the repository into your Unity project's
Packagesdirectory. It will be loaded automatically.
// the namespace
using UnityWebSocket;
// create instance
string address = "ws://echo.websocket.org";
WebSocket socket = new WebSocket(address);
// register callback
socket.OnOpen += OnOpen;
socket.OnClose += OnClose;
socket.OnMessage += OnMessage;
socket.OnError += OnError;
// connect
socket.ConnectAsync();
// send string data
socket.SendAsync(str);
// or send byte[] data (suggested)
socket.SendAsync(bytes);
// close connection
socket.CloseAsync();UNITY_WEB_SOCKET_LOGOpen internal log info.UNITY_WEB_SOCKET_ENABLE_ASYNCUse network thread handle message (not WebGL platform).
See CHANGELOG.md for details.
| Package | Description |
|---|---|
| (无) | - |
- QQ Group: 467608841 / 233840761
See the LICENSE file for details.