StableVersion4.3/HL_FristAidPlatform_Service/Controllers/院前急救系统/UserOnLineController.cs

40 lines
1.2 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
namespace HL_FristAidPlatform_Service.Controllers
{
[Route("api/service/[controller]")]
[ApiController]
[HiddenApiFilter.HiddenApi]
public class UserOnLineController : Controller
{
private IHubContext<ChatHub> hubContext;
/// <summary>
/// 用户上线
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
[HttpGet]
[Route("GetUserOnLine")]
[Authorize(Roles = "GET")]
public JsonResult GetUserOnLine(string userId)
{
if (string.IsNullOrEmpty(userId))
{
return Json("guid参数不能为空");
}
hubContext = typeof(IHubContext<ChatHub>) as IHubContext<ChatHub>;
int userid = 1;
if (PropertyCommon.SignalRConnections.ContainsKey(userid.ToString()))
{
hubContext.Clients.Group(userid.ToString()).SendAsync("receiveNotice ", "您有一个出警任务待处理");
}
return Json("");
}
}
}