All Projects â†’ endel â†’ Nativewebsocket

endel / Nativewebsocket

Licence: other
🔌 WebSocket client for Unity - with no external dependencies (WebGL, Native, Android, iOS, UWP)

Projects that are alternatives of or similar to Nativewebsocket

Unity-2017.2-and-Vuforia-6.5---Camera-Auto-Focus
Unity 2017.2 and Vuforia 6.5 Augmented Reality (AR) Camera Auto Focus
Stars: ✭ 17 (-93.77%)
Mutual labels:  unity-asset, unity3d-plugin
PATCH
The PATCH repository for issues tracking, wiki and shared material.
Stars: ✭ 34 (-87.55%)
Mutual labels:  unity-asset, unity3d-plugin
ar-simulation
AR Simulation for Unity • Right in the Editor • Minimally Invasive
Stars: ✭ 101 (-63%)
Mutual labels:  unity-asset, unity3d-plugin
Csharp Eval Unity3d
C# Expression Parser for Unity3D
Stars: ✭ 102 (-62.64%)
Mutual labels:  unity3d-plugin, unity-asset
JsonFormatter
Easy, Fast and Lightweight Json Formatter. (Serializer and Deserializer)
Stars: ✭ 26 (-90.48%)
Mutual labels:  unity-asset, unity3d-plugin
Apple Signin Unity
Unity plugin to support Sign In With Apple Id
Stars: ✭ 228 (-16.48%)
Mutual labels:  unity3d-plugin, unity-asset
Webview-unity-3d-2017.3-or-higher-
Webview unity 3d 2017.3 or higher - can be open website url on unity3d or open Html5, html and js on unity offline
Stars: ✭ 18 (-93.41%)
Mutual labels:  unity-asset, unity3d-plugin
Savegamepro
A Complete and Powerful Save Game Solution for Unity (Game Engine)
Stars: ✭ 30 (-89.01%)
Mutual labels:  unity3d-plugin, unity-asset
t4-templates-unity3d
T4 Text Template Processor for Unity3D
Stars: ✭ 75 (-72.53%)
Mutual labels:  unity-asset, unity3d-plugin
TsukiSuite
A toolsuite created to make Unity development easier
Stars: ✭ 23 (-91.58%)
Mutual labels:  unity-asset, unity3d-plugin
Dlibfacelandmarkdetector
FaceLandmark Detector using Dlib (Unity Asset Plugin)
Stars: ✭ 80 (-70.7%)
Mutual labels:  unity3d-plugin, unity-asset
unity-firebase-realtime-database
Unity Firebase Realtime Database REST
Stars: ✭ 24 (-91.21%)
Mutual labels:  unity-asset, unity3d-plugin
Awesome Unity Open Source On Github
A categorized collection of awesome Unity open source on GitHub (800+)
Stars: ✭ 1,124 (+311.72%)
Mutual labels:  unity3d-plugin, unity-asset
Jetsonjs
Embed a JavaScript/WebGL application on a Nvidia Jetson TX2 and stream the results through websockets. It does not rely on CUDA/Jetpack. HDMI touchscreen, virtual keyboard, GPIO control, wifi config are included.
Stars: ✭ 18 (-93.41%)
Mutual labels:  webgl, websockets
Energysuite
Simple real-time energy based system for your Unity3d game
Stars: ✭ 31 (-88.64%)
Mutual labels:  unity3d-plugin, unity-asset
UnityHexagonLibrary2d
A library to manage 2D hexagonal tiles in Unity.
Stars: ✭ 58 (-78.75%)
Mutual labels:  unity-asset, unity3d-plugin
Restclient
🦄 Simple HTTP and REST client for Unity based on Promises, also supports Callbacks! 🎮
Stars: ✭ 675 (+147.25%)
Mutual labels:  unity3d-plugin, unity-asset
Uduino
Simple and easy connection between Arduino and Unity
Stars: ✭ 25 (-90.84%)
Mutual labels:  unity3d-plugin, unity-asset
UnityGlobalTextSystem
Allow the user to 'change' the default font in Unity from "Arial" to a font of their liking.
Stars: ✭ 21 (-92.31%)
Mutual labels:  unity-asset, unity3d-plugin
Simple-Unity-Audio-Manager
A decentralized audio playing system for Unity, designed for simplicity and built to scale!
Stars: ✭ 100 (-63.37%)
Mutual labels:  unity-asset, unity3d-plugin
Native WebSocket

This is the simplest and easiest WebSocket library for Unity you can find!

  • No external DLL's required (uses built-in System.Net.WebSockets)
  • WebGL/HTML5 support
  • Supports all major build targets
  • Very simple API

This WebSocket client is used on colyseus-unity3d.
Consider supporting my work on Patreon.
Support me on Patreon

Installation

Requires Unity 2019.1+ with .NET 4.x+ Runtime

Install via UPM (Unity Package Manager)

  1. Open Unity
  2. Open Package Manager Window
  3. Click Add Package From Git URL
  4. Enter URL: https://github.com/endel/NativeWebSocket.git#upm

Install manually

  1. Download this project
  2. Copy the sources from NativeWebSocket/Assets/WebSocket into your Assets directory.

Usage

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using NativeWebSocket;

public class Connection : MonoBehaviour
{
  WebSocket websocket;

  // Start is called before the first frame update
  async void Start()
  {
    websocket = new WebSocket("ws://localhost:2567");

    websocket.OnOpen += () =>
    {
      Debug.Log("Connection open!");
    };

    websocket.OnError += (e) =>
    {
      Debug.Log("Error! " + e);
    };

    websocket.OnClose += (e) =>
    {
      Debug.Log("Connection closed!");
    };

    websocket.OnMessage += (bytes) =>
    {
      Debug.Log("OnMessage!");
      Debug.Log(bytes);

      // getting the message as a string
      // var message = System.Text.Encoding.UTF8.GetString(bytes);
      // Debug.Log("OnMessage! " + message);
    };

    // Keep sending messages at every 0.3s
    InvokeRepeating("SendWebSocketMessage", 0.0f, 0.3f);

    // waiting for messages
    await websocket.Connect();
  }

  void Update()
  {
    #if !UNITY_WEBGL || UNITY_EDITOR
      websocket.DispatchMessageQueue();
    #endif
  }

  async void SendWebSocketMessage()
  {
    if (websocket.State == WebSocketState.Open)
    {
      // Sending bytes
      await websocket.Send(new byte[] { 10, 20, 30 });

      // Sending plain text
      await websocket.SendText("plain text message");
    }
  }

  private async void OnApplicationQuit()
  {
    await websocket.Close();
  }

}

Demonstration

1. Start the local WebSocket server:

cd Server
npm install
npm start

2. Open the NativeWebSocket/Assets/WebSocketExample/WebSocketExampleScene.unity on Unity and Run.

Acknowledgements

Big thanks to Jiri Hybek. This implementation is based on his work.

License

Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].