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
typescript
| 1 | import { io } from "socket.io-client"; |
| 2 | |
| 3 | const 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:
| Parameter | Type | Requirement | Description |
|---|---|---|---|
| user_[userId] | Auto-Join | Optional | Private room for user-specific notifications and Direct Messages. |
| project_lobby_[projectId] | Explicit Join | Optional | Broadcasts global events (e.g. New Donations, Live Deployments) to all active project admins. |
| thread_[threadId] | Explicit Join | Optional | Binds the client to a specific Omnichannel chat thread to receive typing indicators and incoming messages. |
Event Packet Dictionary
json
| 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 | } |