# Class WebSocketMessageService

Namespace
  adas_core.WebSocket

Assembly
  adas-core.dll

    public class WebSocketMessageService : IClientMessageService

Inheritance
  object
  WebSocketMessageService

Implements
  IClientMessageService

Inherited Members
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## Constructors

### WebSocketMessageService(Lazy<IPatientService>, Lazy<IObservationService>, Lazy<IPumpService>, Lazy<ITreatmentService>, IGroupedObservationService, IConfigObservationService, Lazy<IAppointmentService>, IRelayService, IOptions<ApiSettings>, IOptions<RecordingSettings>, Lazy<IRecordingService>, IHubContext<UciHub>, Lazy<ILightBeaconService>, Lazy<IDiagnosisService>, Lazy<IAlarmService>, ISubscribersService, ISubscriberGroupedService, Lazy<IDisplayService>, Lazy<IUnitService>, Lazy<IAdmissionService>, Lazy<IDischargeService>, Lazy<INoticeService>, IObservationDemoService)

    public WebSocketMessageService(Lazy<IPatientService> patientService, Lazy<IObservationService> observationService, Lazy<IPumpService> pumpService, Lazy<ITreatmentService> treatmentService, IGroupedObservationService groupedObservationService, IConfigObservationService configObservationService, Lazy<IAppointmentService> appointmentService, IRelayService relayService, IOptions<ApiSettings> apiSettings, IOptions<RecordingSettings> recordingSettings, Lazy<IRecordingService> recordingService, IHubContext<UciHub> hub, Lazy<ILightBeaconService> lightBeaconService, Lazy<IDiagnosisService> diagnosisService, Lazy<IAlarmService> alarmService, ISubscribersService subscribersService, ISubscriberGroupedService subscriberGroupedService, Lazy<IDisplayService> displayService, Lazy<IUnitService> unitService, Lazy<IAdmissionService> admissionService, Lazy<IDischargeService> dischargeService, Lazy<INoticeService> noticeService, IObservationDemoService observationDemoService)

#### Parameters

`patientService` Lazy<IPatientService>
`observationService` Lazy<IObservationService>
`pumpService` Lazy<IPumpService>
`treatmentService` Lazy<ITreatmentService>
`groupedObservationService` IGroupedObservationService
`configObservationService` IConfigObservationService
`appointmentService` Lazy<IAppointmentService>
`relayService` IRelayService
`apiSettings` IOptions<ApiSettings>
`recordingSettings` IOptions<RecordingSettings>
`recordingService` Lazy<IRecordingService>
`hub` IHubContext<UciHub>
`lightBeaconService` Lazy<ILightBeaconService>
`diagnosisService` Lazy<IDiagnosisService>
`alarmService` Lazy<IAlarmService>
`subscribersService` ISubscribersService
`subscriberGroupedService` ISubscriberGroupedService
`displayService` Lazy<IDisplayService>
`unitService` Lazy<IUnitService>
`admissionService` Lazy<IAdmissionService>
`dischargeService` Lazy<IDischargeService>
`noticeService` Lazy<INoticeService>
`observationDemoService` IObservationDemoService

## Methods

### ProcessMessage(Message, string)

Processes an incoming message by routing it to the appropriate handler based on the subscription type. Handles ChatMessage, RecordingSuscribe, PatientData, GroupedObservations, Admin, Display, BoxSubscribe, Demo, and Idle operations.

    public Task ProcessMessage(Message msg, string connectionId)

#### Parameters

`msg` Message

  The message to process, containing the operation type and payload.

`connectionId` string

  The identifier of the connection that originated the message.

#### Returns

Task

### SendAsync(string, OperationType?, object?)

Asynchronously serializes the provided message to JSON using camelCase property naming and string-based enum conversion, then delivers it to the SignalR client identified by `subscriberId` via the "ReceiveMessage" event.

    public Task SendAsync(string subscriberId, OperationType? type, object? msg)

#### Parameters

`subscriberId` string

  The identifier of the SignalR client connection that should receive the message.

`type` OperationType?

  The optional operation type associated with the message, included in the payload as its string representation when present.

`msg` object

  The message object to serialize and send. May be `null`.

#### Returns

Task

### SendToAllAsync(OperationType, object?)

Asynchronously broadcasts a message of the specified operation type to all connected SignalR clients, serializing the payload using camelCase JSON with ISO date formatting, suppression of null and default values, and roundtrip DateTime kind preservation.

    public Task SendToAllAsync(OperationType type, object? msg)

#### Parameters

`type` OperationType

  The operation type that identifies the kind of message being broadcast.

`msg` object

  The message payload to serialize and send. Can be null.

#### Returns

Task

### SendUpdateMessageToBoxes(List<PatientLocation>)

Sends an update message to all subscribers associated with the given patient locations. If the location has no bed specified, subscribers are matched by section; otherwise, subscribers are matched by both box (bed) and section.

    public void SendUpdateMessageToBoxes(List<PatientLocation> patientLocations)

#### Parameters

`patientLocations` List<PatientLocation>

  The list of patient locations used to determine which subscribers should receive the update message.