NativeWebSocket is a small WebSocket client for Unity, MonoGame, Godot, and general .NET projects. It uses built-in System.Net.WebSockets without extra native DLLs.
Overview
NativeWebSocket provides a WebSocket client for game engines and .NET applications that need real-time connectivity without shipping additional native dependencies. It wraps System.Net.WebSockets and targets netstandard2.0 and modern .NET so the same core runs across environments.
Unity installs via Unity Package Manager or a packaged asset; WebGL builds are supported with documented background-run settings. MonoGame projects can add a game component that wires SynchronizationContext so callbacks run on the game thread. Godot Mono routes events on the main thread through its built-in synchronization context.
The API exposes connect, send text or binary, close with codes, and events for open, message, error, and close. When no SynchronizationContext exists, callers can drain a message queue from their main loop. The library is used by projects such as the Colyseus Unity SDK.
Version 2 removed UnityEngine coupling from the core, added automatic main-thread dispatch, and requires UPM or unitypackage install because WebGL needs build-time source transforms.
Key features
- No external WebSocket DLLs
- Unity WebGL and native builds
- MonoGame and Godot Mono support
- Main-thread event dispatch
- Text and binary send and receive
- Simple connect and close API
- netstandard2.0 and .NET 6 targets
- UPM and unitypackage distribution
Use cases
- Real-time multiplayer game clients
- Unity WebGL browser WebSocket apps
- Godot C# networked tools
- MonoGame live data feeds
- Generic .NET WebSocket clients