Endpoint
Authentication
The glasses WebSocket requires a JWT token in the Authorization header. This token is obtained from the mobile app after user authentication.Headers
JWT Token Structure
The coreToken must contain:sub: User identifieremail: User’s email addressorganizations: Array of user’s organizations (optional)defaultOrg: Default organization (optional)
Connection Flow
1
Authentication
Mobile app sends JWT token in Authorization header
2
Validation
Server validates JWT token using
AUGMENTOS_AUTH_JWT_SECRET3
Session Creation
If valid, creates or retrieves UserSession for the user
4
Connection Init
Client must send CONNECTION_INIT message within 30 seconds
Message Types
Client → Server Messages
All message types are defined inpackages/sdk/src/types/messages/glasses-to-cloud.ts:
CONNECTION_INIT
BUTTON_PRESS
HEAD_POSITION
LOCATION_UPDATE
PHOTO_TAKEN
START_APP / STOP_APP
Server → Client Messages
All message types are defined inpackages/sdk/src/types/messages/cloud-to-glasses.ts:
CONNECTION_ACK
CONNECTION_ERROR
DISPLAY_EVENT
PHOTO_REQUEST
Error Handling
Authentication Errors
If authentication fails, the server responds with HTTP 401:Connection Timeout
If CONNECTION_INIT is not received within 30 seconds:Heartbeat
The server sends WebSocket ping frames every 10 seconds to check connection health. The client must respond with pong frames or the connection will be closed.Implementation Details
- Service:
GlassesWebSocketService(packages/cloud/src/services/websocket/websocket-glasses.service.ts) - Authentication: JWT validation in
setupWebSocketServersmethod - Session Management:
UserSessionclass manages the connection lifecycle - Message Routing: Messages are routed to appropriate managers in the UserSession