|
@@ -114,7 +114,7 @@ export class VisionGateway
|
|
|
complete: true,
|
|
complete: true,
|
|
|
payload: metrics,
|
|
payload: metrics,
|
|
|
};
|
|
};
|
|
|
- this.server?.emit('response', packet);
|
|
|
|
|
|
|
+ this.server?.to('telemetry-room').emit('response', packet);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -142,6 +142,7 @@ export class VisionGateway
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
handleDisconnect(client: Socket) {
|
|
handleDisconnect(client: Socket) {
|
|
|
|
|
+ client.leave('telemetry-room');
|
|
|
this.logger.log(`🔌 Vision client disconnected: ${client.id}`);
|
|
this.logger.log(`🔌 Vision client disconnected: ${client.id}`);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -154,13 +155,15 @@ export class VisionGateway
|
|
|
* Routing key: `${serviceId}:${operation}`
|
|
* Routing key: `${serviceId}:${operation}`
|
|
|
*
|
|
*
|
|
|
* Supported routes:
|
|
* Supported routes:
|
|
|
- * PalmVision:analyze — decode Base64 frame, run ONNX, persist, reply
|
|
|
|
|
- * History:getAll — fetch last 50 history records
|
|
|
|
|
- * History:delete — delete one record by archiveId
|
|
|
|
|
- * History:clearAll — wipe all records and archived images
|
|
|
|
|
- * Chat:send — proxy message to n8n webhook
|
|
|
|
|
- * Chat:clear — reset session UUID
|
|
|
|
|
- * PalmHistory:GetImage — stream archived image as Base64 data URL
|
|
|
|
|
|
|
+ * PalmVision:analyze — decode Base64 frame, run ONNX, persist, reply
|
|
|
|
|
+ * History:getAll — fetch last 50 history records
|
|
|
|
|
+ * History:delete — delete one record by archiveId
|
|
|
|
|
+ * History:clearAll — wipe all records and archived images
|
|
|
|
|
+ * Chat:send — proxy message to n8n webhook
|
|
|
|
|
+ * Chat:clear — reset session UUID
|
|
|
|
|
+ * PalmHistory:GetImage — stream archived image as Base64 data URL
|
|
|
|
|
+ * Surveillance:SubscribeTelemetry — join telemetry-room for metric push
|
|
|
|
|
+ * Surveillance:UnsubscribeTelemetry — leave telemetry-room
|
|
|
*/
|
|
*/
|
|
|
@SubscribeMessage('request')
|
|
@SubscribeMessage('request')
|
|
|
async handleMessage(
|
|
async handleMessage(
|
|
@@ -340,6 +343,31 @@ export class VisionGateway
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // ── Surveillance:SubscribeTelemetry ────────────────────────────────
|
|
|
|
|
+ case 'Surveillance:SubscribeTelemetry': {
|
|
|
|
|
+ await client.join('telemetry-room');
|
|
|
|
|
+ this.logger.log(`📊 ${client.id} joined telemetry-room`);
|
|
|
|
|
+ const snapshot = this.surveillanceService.getLatestMetrics();
|
|
|
|
|
+ if (snapshot) {
|
|
|
|
|
+ const snapId = crypto.randomUUID();
|
|
|
|
|
+ client.emit('response', {
|
|
|
|
|
+ id: snapId, messageID: snapId,
|
|
|
|
|
+ serviceId: 'Surveillance', operation: 'metricsUpdate',
|
|
|
|
|
+ complete: true, payload: snapshot,
|
|
|
|
|
+ } satisfies FisAppResponse);
|
|
|
|
|
+ }
|
|
|
|
|
+ reply({ status: 'subscribed' });
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // ── Surveillance:UnsubscribeTelemetry ──────────────────────────────
|
|
|
|
|
+ case 'Surveillance:UnsubscribeTelemetry': {
|
|
|
|
|
+ await client.leave('telemetry-room');
|
|
|
|
|
+ this.logger.log(`📊 ${client.id} left telemetry-room`);
|
|
|
|
|
+ reply({ status: 'unsubscribed' });
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// ── Unknown route ──────────────────────────────────────────────────
|
|
// ── Unknown route ──────────────────────────────────────────────────
|
|
|
default: {
|
|
default: {
|
|
|
this.logger.warn(`⚠️ Unknown route: ${route}`);
|
|
this.logger.warn(`⚠️ Unknown route: ${route}`);
|