private static void _transport_MessageReceived(object sender, byte[] e) { var pelcoMessage = PelcoDEMessage.FromBytes(e); _logger.LogInfoMessage($"Pelco message received => {pelcoMessage?.ToString() ?? "<null>"}"); if (pelcoMessage == null) { return; } _cts.Dispose(); var trySetResult = _sendMessageTaskCompletionSource?.TrySetResult(pelcoMessage); _logger.LogInfoMessage($"Set async task result: {trySetResult}"); }
private void transport_MessageReceived(object sender, byte[] messageData) { var pelcoMessage = PelcoDEMessage.FromBytes(messageData); _logger.LogInfoMessage($"Pelco message received => {pelcoMessage?.ToString() ?? "<null>"}"); if (pelcoMessage == null) { return; } var settings = _settingsManager.GetAppSettings(); var responseType = _responseDecoder.GetResponseType(pelcoMessage); _logger.LogInfoMessage($"Pelco response type => {responseType?.ToString() ?? "<null>"}"); switch (responseType) { case null: return; case PelcoDEMessageType.SetPanCompleteResponse: _panTaskCompletionSource?.TrySetResult(true); return; case PelcoDEMessageType.RequestPanResponse: { var panAngleToCoordinatesFactor = settings.PTZPanAngleToCoordinateFactor; var angle = PelcoResponseDecoder.GetUInt16(pelcoMessage) / panAngleToCoordinatesFactor / 100; _logger.LogDebugMessage($"Pelco RequestPanResponse received => angle: {angle}"); _panRequestCTS.Dispose(); _requestPanTaskCompletionSource?.TrySetResult(angle); return; } case PelcoDEMessageType.RequestTiltResponse: { var tiltAngleToCoordinatesFactor = settings.PTZTiltAngleToCoordinateFactor; var angle = PelcoResponseDecoder.GetUInt16(pelcoMessage) / tiltAngleToCoordinatesFactor / 100; _logger.LogDebugMessage($"Pelco RequestTiltResponse received => angle: {angle}"); _tiltRequestCTS.Dispose(); _requestTiltTaskCompletionSource?.TrySetResult(angle); return; } } }