Initial commit
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using RobotNet10.RobotApp.Client.Shared.Devices;
|
||||
using RobotNet10.RobotApp.Devices;
|
||||
using RobotNet10.Shared.Geometry;
|
||||
|
||||
namespace RobotNet10.RobotApp.Hubs;
|
||||
|
||||
/// <summary>
|
||||
/// SignalR Hub cho Camera QR device - cung cấp real-time QR detection data
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
public class CameraQrHub(IDeviceProvider deviceProvider) : Hub
|
||||
{
|
||||
/// <summary>
|
||||
/// Lấy thông tin device (DeviceName) theo device ID
|
||||
/// </summary>
|
||||
public async Task<DeviceInfoDto?> GetDeviceInfo(string deviceId)
|
||||
{
|
||||
var device = deviceProvider.GetDevice(deviceId);
|
||||
if (device is not ICameraQr)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DeviceInfoDto
|
||||
{
|
||||
DeviceId = device.DeviceId,
|
||||
DeviceName = device.DeviceName
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lấy dữ liệu Camera QR theo device ID
|
||||
/// </summary>
|
||||
public async Task<CameraQrDataDto?> GetCameraQrData(string deviceId)
|
||||
{
|
||||
var device = deviceProvider.GetDevice(deviceId);
|
||||
if (device is not ICameraQr cameraQr)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return MapToDto(cameraQr);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Map ICameraQr sang CameraQrDataDto
|
||||
/// </summary>
|
||||
private static CameraQrDataDto MapToDto(ICameraQr cameraQr)
|
||||
{
|
||||
return new CameraQrDataDto
|
||||
{
|
||||
IsConnected = cameraQr.IsConnected,
|
||||
Codes = cameraQr.Codes,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user