68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.Logging;
|
|
using xPushService.Interfaces;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using xPushService.Constants;
|
|
using xCommons.Extensions;
|
|
|
|
namespace xPushService.Base
|
|
{
|
|
public abstract class XBaseWebRTCHub : XBaseHub, IXBaseWebRTCHub
|
|
{
|
|
//
|
|
#region Props ...
|
|
#endregion
|
|
|
|
//
|
|
#region Constructor ...
|
|
protected XBaseWebRTCHub(
|
|
ILogger<XBaseHub> logger
|
|
) : base(logger)
|
|
{ }
|
|
#endregion
|
|
|
|
//
|
|
#region WebRTCActions ...
|
|
/// <summary>
|
|
/// Sending WebRTC Offer To Specified Connection ...
|
|
/// </summary>
|
|
/// <param name="offer"></param>
|
|
/// <param name="to"></param>
|
|
/// <returns></returns>
|
|
public async Task Offer(string offer, string to)
|
|
{
|
|
await Clients.Client(to).SendAsync(XWebRTCAction.Offer.GetStringValue(), offer);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sending WebRTC Answer to Specified Connection ...
|
|
/// </summary>
|
|
/// <param name="answer"></param>
|
|
/// <returns></returns>
|
|
public async Task Answer(string answer)
|
|
{
|
|
await Clients.All.SendAsync(XWebRTCAction.Answer.GetStringValue(), answer, Context.ConnectionId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sending WebRTC Candidate to Specified Connecton ...
|
|
/// </summary>
|
|
/// <param name="candidate"></param>
|
|
/// <param name="to"></param>
|
|
/// <returns></returns>
|
|
public async Task Candidate(string candidate, string to)
|
|
{
|
|
//
|
|
string actionName = XWebRTCAction.Candidate.GetStringValue();
|
|
if (!string.IsNullOrEmpty(to))
|
|
{
|
|
await Clients.Client(to).SendAsync(actionName, candidate, Context.ConnectionId);
|
|
}
|
|
else
|
|
{
|
|
await Clients.All.SendAsync(actionName, candidate, Context.ConnectionId);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |