11. API & Protocols/Real-Time Streaming

WebSocket Wire Protocol

GN-Apex leverages persistent WebSocket connections via Socket.io to push real-time inbox messages, live analytics telemetry, and presence collision states to authenticated clients.

STATEFUL CONNECTIVITY
WSS://
Secure WebSocket Stream

Bi-directional events enable instant chat collaboration and live dashboard metric rendering without continuous HTTP polling.

Event-Driven Presence Mesh

Connection Handshake

Clients connect to the gateway and authenticate passing their JWT in the handshake payload.

WSwss://api.gnapex.com/notifications
1import { io } from "socket.io-client";
2 
3const socket = io("wss://api.gnapex.com/notifications", {
4 auth: { token: "eyJhbGciOiJIUzI1NiIs..." },
5 transports: ["websocket"],
6});

Namespace & Subscription Rooms

Upon connection, the server automatically drops the client into private rooms, but clients can also explicitly join operational spaces:

ParameterTypeRequirementDescription
user_[userId]Auto-JoinOptionalPrivate room for user-specific notifications and Direct Messages.
project_lobby_[projectId]Explicit JoinOptionalBroadcasts global events (e.g. New Donations, Live Deployments) to all active project admins.
thread_[threadId]Explicit JoinOptionalBinds the client to a specific Omnichannel chat thread to receive typing indicators and incoming messages.

Event Packet Dictionary

1// Emitted to thread_[threadId]
2{
3 "threadId": "thr_998877",
4 "message": {
5 "id": "msg_123",
6 "direction": "INBOUND",
7 "content": "Is this product still in stock?",
8 "status": "DELIVERED"
9 }
10}