Skip to content
 
 

Latest commit

 

History

219 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Game Frame X Logo

Game Frame X UnityWebSocket

License Version Unity Version Documentation

All-in-One Solution for Indie Game Development · Empowering Indie Developers' Dreams


Documentation · Quick Start · QQ Group: 467608841 / 233840761


English | 简体中文 | 繁體中文 | 日本語 | 한국어

Language

English | 简体中文 | 繁體中文 | 日本語 | 한국어


Project Overview

WebSocket library for Unity. This library primarily serves as a sub-library for https://github.com/AlianBlank/GameFrameX.

Quick Start

Installation

Choose one of the following methods:

  1. Edit your Unity project's Packages/manifest.json and add the scopedRegistries section:

    {
      "scopedRegistries": [
        {
          "name": "GameFrameX",
          "url": "https://gameframex.upm.alianblank.uk",
          "scopes": [
            "com.gameframex"
          ]
        }
      ],
      "dependencies": {
        "com.gameframex.unity.psygames.unitywebsocket": "2.9.2"
      }
    }

    scopes controls which packages are resolved through this registry. Only packages whose names start with com.gameframex will be fetched from it.

  2. Add to manifest.json dependencies:

    {
       "com.gameframex.unity.psygames.unitywebsocket": "https://github.com/gameframex/com.gameframex.unity.psygames.unitywebsocket.git"
    }
  3. Use Package Manager in Unity with Git URL: https://github.com/gameframex/com.gameframex.unity.psygames.unitywebsocket.git

  4. Clone the repository into your Unity project's Packages directory. It will be loaded automatically.

Usage Examples

Online Demo

Basic Usage

// 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 Define Symbols (Optional)

  • UNITY_WEB_SOCKET_LOG Open internal log info.
  • UNITY_WEB_SOCKET_ENABLE_ASYNC Use network thread handle message (not WebGL platform).

Changelog

See CHANGELOG.md for details.

Dependencies

Package Description
(无) -

Documentation & Resources

Community & Support

  • QQ Group: 467608841 / 233840761

License

See the LICENSE file for details.

About

UnityWebSocket - Lightweight WebSocket client library for Unity with cross-platform support and easy-to-use API

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages