Skip to main content

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:

AttemptDelay
10 seconds (immediate)
22 seconds
34 seconds
48 seconds
516 seconds
6+30 seconds (max)

Broadcast Methodsโ€‹

MethodTriggered ByPayload
BroadcastImageToGroupSingle image capturedImage metadata (URL, timestamp, PTZ, device ID)
BroadcastPanoImageToGroupPanoramic image capturedPano metadata (URL, component count, device ID)
BroadcastCurrentConfigToGroupMode/status changeCurrent camera config and state

When Broadcasting Happensโ€‹

Broadcasting occurs at the end of each image storage operation:

  1. Image capture โ†’ stored in Blob Storage โ†’ metadata saved to Table Storage โ†’ broadcast to SignalR
  2. Mode transition โ†’ entity state updated โ†’ broadcast current config
  3. 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.