How megatran/hololens_websocket_uwp works
Project Type & Purpose
• This is a Unity-based Mixed Reality client (UWP/HoloLens) that communicates over WebSockets to a multi-platform WebSocket server (Python or NodeJS).
• The Assets folder is the Unity project (with HoloToolkit/MRTK packages and custom C# scripts), and the python-websocket folder contains simple echo/chat server examples.
Architectural Components
• Unity/MRTK Client (UWP App on HoloLens)
• C# scripts under Assets/Scripts and Assets/HoloToolkit handle WebSocket connections.
• TestWebsocketSender.cs uses the UwpWebsocket wrapper to open “ws://…:8000/” and send/receive text messages.
• Scene “holoSocket.unity” hosts an input mechanism or display logic to show server messages.
• WebSocket Server
• Python echo_socket_server.py (simple echo behavior)
• Python chat_server.py (bidirectional chat)
• Or a NodeJS ws-based server.
• Optional Web Client
• websocket.html in python-websocket for testing in a browser.
• Network Infrastructure
• HoloLens device and server must share a network (Wi-Fi or Ethernet), reachable via the specified URI.
Interactions & Data Flows
• The HoloLens app (WebSocket Client) establishes a persistent TCP/WebSocket connection to the server endpoint on port 8000.
• User input or gaze gestures in Unity become messages sent over that socket.
• The server broadcasts incoming messages to all connected clients (HoloLens, browser, CLI).
• Responses or echoes flow back over the same connection and are rendered by the Unity app’s UI.
Key Architectural Patterns
• Publish/Subscribe over WebSocket: the server acts as a message broker, broadcasting to all subscribers.
• Component separation in Unity:
• Presentation/Scene Assets (Scenes, Prefabs)
• Communication Layer (TestWebsocketSender.cs, UwpWebsocket.cs)
• Toolkit/Utilities (HoloToolkit modules provide input, boundary, spatial mapping, etc.)
Technologies & Frameworks
• Unity 2018+ targeting UWP/HoloLens
• Microsoft Mixed Reality Toolkit (HoloToolkit) for input, UX, spatial mapping
• C# UwpWebsocket library (Assets/Scripts/UwpWebsocket.cs)
• Python 3 + simple-websocket-server or NodeJS ws module
• Optional web front-end (HTML/JS) for browser connectivity