SignalR Integration
The Image Acquisition Engine uses a SignalR client to broadcast image metadata and camera status updates in real-time to connected frontends. This enables the frontend to display live camera feeds without polling.
Architectureโ
SignalRConnectionServiceโ
The SignalRConnectionService is registered as a singleton and manages a persistent connection to the SignalR hub.
Hub URLโ
{NEXT_PUBLIC_API_DOMAIN}/cameraHub
Auto-Reconnectโ
The connection uses exponential backoff reconnection:
| Attempt | Delay |
|---|---|
| 1 | 0 seconds (immediate) |
| 2 | 2 seconds |
| 3 | 4 seconds |
| 4 | 8 seconds |
| 5 | 16 seconds |
| 6+ | 30 seconds (max) |
Broadcast Methodsโ
| Method | Triggered By | Payload |
|---|---|---|
BroadcastImageToGroup | Single image captured | Image metadata (URL, timestamp, PTZ, device ID) |
BroadcastPanoImageToGroup | Panoramic image captured | Pano metadata (URL, component count, device ID) |
BroadcastCurrentConfigToGroup | Mode/status change | Current camera config and state |
When Broadcasting Happensโ
Broadcasting occurs at the end of each image storage operation:
- Image capture โ stored in Blob Storage โ metadata saved to Table Storage โ broadcast to SignalR
- Mode transition โ entity state updated โ broadcast current config
- PTZ change โ position updated โ broadcast to SignalR (via
RefreshPTZForFE)
RefreshPTZForFE Timer Functionโ
A timer-triggered function runs every 5 minutes to sync PTZ position data from durable entities to the CameraOperationalEntity:
- Reads current PTZ positions from all active durable entities
- Updates the
CameraOperationalEntity(used by the frontend for map arrow rotation) - Ensures the frontend map stays synchronized even if individual SignalR broadcasts are missed
Group-Based Broadcastingโ
Messages are sent to groups identified by device ID. Frontend clients subscribe to specific camera groups to receive updates only for cameras they're viewing. This prevents unnecessary network traffic for cameras the user isn't monitoring.