English | 简体中文 | 繁體中文 | 日本語 | 한국어
WebSocket library for Unity. This library primarily serves as a sub-library for https://github.com/AlianBlank/GameFrameX.
-
Add the following content directly to
manifest.json:{"com.gameframex.unity.psygames.unitywebsocket": "https://github.com/AlianBlank/com.gameframex.unity.psygames.unitywebsocket.git"} -
Add via Unity's
Package ManagerusingGit URL: https://github.com/AlianBlank/com.gameframex.unity.psygames.unitywebsocket.git -
Download the repository directly and place it in the Unity project's
Packagesdirectory. It will be auto-loaded.
- Added
IsConnectedproperty.
// 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.
See the LICENSE file for details.
