Smart Device Client - WebSocket Protocol Help

Overview

The Smart Device Client uses a WebSocket-based protocol powered by Socket.IO to facilitate real-time communication between devices in a meeting. This document describes the connection process, supported events, and command formats.

Connection

Clients connect to the server using Socket.IO at the /io namespace. The connection requires two query parameters:

Example connection (JavaScript):

const socket = io('/io', {
  query: { meetId: 'room1', email: 'user1@example.com' }
});

Events

Server-to-Client Events

Event Description Payload
connect Triggered when the client successfully connects to the server. None
connectionError Triggered if the connection fails (e.g., missing query parameters).
{ message: string }
deviceConnected Triggered when a device joins the meeting.
{ deviceId: string, email: string, meetId: string, totalDevices: number }
deviceDisconnected Triggered when a device leaves the meeting.
{ deviceId: string, email: string, meetId: string, totalDevices: number }
deviceMessage Triggered when a device broadcasts a message.
{ senderId: string, senderEmail: string, message: string, timestamp: string }
control Triggered when a control command is received.
{ senderId: string, senderEmail: string, command: string, data?: any, timestamp: string }
controlError Triggered if a control command fails (e.g., invalid JSON).
{ message: string }
deviceList Triggered in response to getDeviceList, listing all connected devices.
{ devices: [{ id: string, email: string }], total: number, meetId: string }

Client-to-Server Events

Event Description Payload
getDeviceList Requests the list of connected devices in the meeting. None
broadcast Sends a message to all devices in the meeting.
string
control Sends a control command to a specific device.
{ targetEmail: string, command: string, data?: any }

Control Command Format

Control commands sent via the control event must include:

Example valid control command:

socket.emit('control', {
  targetEmail: 'user2@example.com',
  command: 'custom',
  data: { command: 'stop' }
});

Invalid JSON in data (e.g., {command:"stop"}) will trigger a controlError event.

Usage Notes