|
@@ -33,6 +33,7 @@ using WingInterfaceLibrary.Enum.CommentEnum;
|
|
|
using WingInterfaceLibrary.DTO.RTC;
|
|
|
using Newtonsoft.Json;
|
|
|
using WingInterfaceLibrary.Notifications.Live;
|
|
|
+using WingInterfaceLibrary.Enum.NotificationEnum;
|
|
|
|
|
|
namespace WingDeviceService.Service
|
|
|
{
|
|
@@ -1119,7 +1120,7 @@ namespace WingDeviceService.Service
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
- //新增或更新设备直播间
|
|
|
+ //新增或更新设备直播间 TODO
|
|
|
var rtcRoomResult = await _rtcService.GetRoomIdAsync(new GetRoomIdRequest
|
|
|
{
|
|
|
UniqueId = deviceCode,
|
|
@@ -1150,6 +1151,7 @@ namespace WingDeviceService.Service
|
|
|
MergedVideoOutputHeight = deviceMemberInfo.MergedVideoOutputHeight,
|
|
|
VideoDeviceOutputList = deviceMemberInfo.VideoDeviceInfos.ToList(),
|
|
|
};
|
|
|
+ await BroadcastNotificationAsync(liveRoom.RoomId, new List<string> { deviceCode }, message);
|
|
|
return new JoinDeviceLiveRoomResult
|
|
|
{
|
|
|
RoomNo = initiateResult.RoomNo,
|
|
@@ -1175,6 +1177,7 @@ namespace WingDeviceService.Service
|
|
|
var liveRoom = liveRooms?.FirstOrDefault(x => x.Status == LiveRoomStatus.Initiating);
|
|
|
if (liveRoom != null)
|
|
|
{
|
|
|
+ var deviceCode = liveRoom.DeviceInfos?.FirstOrDefault()?.Id;
|
|
|
//移除观众
|
|
|
var removeViewerResult = await _rtcService.RemoveViewerAsync(new RemoveViewerRequest
|
|
|
{
|
|
@@ -1182,13 +1185,14 @@ namespace WingDeviceService.Service
|
|
|
UserCode = userInfo.ClientId,
|
|
|
});
|
|
|
var expireTime = DateTime.UtcNow.AddSeconds(_reportStateTimeout * -1);
|
|
|
- if (!liveRoom.ViewerInfos.Any(x => x.UserCode != userCode && x.LastReportTime >= expireTime))
|
|
|
+ if (!liveRoom.ViewerInfos.Any(x => x.UserCode != userCode && x.LastReportTime >= expireTime) && !string.IsNullOrWhiteSpace(deviceCode))
|
|
|
{
|
|
|
//关闭直播 to device
|
|
|
var message = new CloseLiveToDeviceNotification
|
|
|
{
|
|
|
LiveRoomCode = liveRoom.RoomId,
|
|
|
};
|
|
|
+ await BroadcastNotificationAsync(liveRoom.RoomId, new List<string> { deviceCode }, message);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
@@ -1260,6 +1264,7 @@ namespace WingDeviceService.Service
|
|
|
{
|
|
|
LiveRoomCode = liveRoom.RoomId,
|
|
|
};
|
|
|
+ await BroadcastNotificationAsync(liveRoom.RoomId, validViewers.Select(x => x.UserCode).ToList(), message);
|
|
|
}
|
|
|
if (request.LiveState == DeviceLiveStateEnum.Pushing && !validViewers.Any())
|
|
|
{
|
|
@@ -1268,6 +1273,7 @@ namespace WingDeviceService.Service
|
|
|
{
|
|
|
LiveRoomCode = liveRoom.RoomId,
|
|
|
};
|
|
|
+ await BroadcastNotificationAsync(liveRoom.RoomId, new List<string> { deviceCode }, message);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1306,6 +1312,21 @@ namespace WingDeviceService.Service
|
|
|
RoomNo = intRoomNo,
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+ private async Task<bool> BroadcastNotificationAsync(string roomId, IList<string> clientIds, NotificationDTO message)
|
|
|
+ {
|
|
|
+ var broadcastNotificationRequest = new BroadcastRoomNotificationRequest
|
|
|
+ {
|
|
|
+ RoomId = roomId,
|
|
|
+ ClientIds = clientIds,
|
|
|
+ Message = message,
|
|
|
+ TransactionType = TransactionTypeEnum.Live,
|
|
|
+ RelevanceCode = roomId,
|
|
|
+ ReceiverType = ApplicantTypeEnum.Client,
|
|
|
+ WSConnectType = WSConnectTypeEnum.Default
|
|
|
+ };
|
|
|
+ return await _rtcService.BroadcastRoomNotificationAsync(broadcastNotificationRequest);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|