35 lines
820 B
C#
35 lines
820 B
C#
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using _0_Framework.Application;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace CompanyManagment.App.Contracts.Hubs;
|
|
|
|
|
|
public class SendSmsHub : Hub
|
|
{
|
|
private readonly IAuthHelper _authHelper;
|
|
|
|
public SendSmsHub(IAuthHelper authHelper)
|
|
{
|
|
_authHelper = authHelper;
|
|
}
|
|
|
|
public override async Task OnConnectedAsync()
|
|
{
|
|
var accountId = _authHelper.CurrentAccountId();
|
|
var connectionId = Context.ConnectionId;
|
|
await send(accountId);
|
|
await base.OnConnectedAsync();
|
|
}
|
|
|
|
public async Task send(long id)
|
|
{
|
|
await Groups.AddToGroupAsync(Context.ConnectionId, GetGroupName(id));
|
|
}
|
|
|
|
public static string GetGroupName(long id)
|
|
{
|
|
return $"group-sms-{id}";
|
|
}
|
|
} |