平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

49 lines
1.4 KiB

  1. namespace SafeCampus.Plugin.SignalR
  2. {
  3. /// <summary>
  4. /// <inheritdoc cref="INoticeService"/>
  5. /// </summary>
  6. [Injection(Named = "signalr")]
  7. public class SignalrNoticeService : INoticeService
  8. {
  9. public SignalrNoticeService()
  10. {
  11. }
  12. /// <inheritdoc/>
  13. public async Task UpdatePassWord(string userId, List<string> clientIds, string message)
  14. {
  15. //发送消息给用户
  16. await GetHubContext().Clients.Users(clientIds).NewMessage(message);
  17. }
  18. /// <inheritdoc/>
  19. public async Task NewMesage(List<string> userIds, List<string> clientIds, string message)
  20. {
  21. //发送消息给用户
  22. await GetHubContext().Clients.Users(clientIds).NewMessage(message);
  23. }
  24. /// <inheritdoc/>
  25. public async Task UserLoginOut(string userId, List<string> clientIds, string message)
  26. {
  27. //发送消息给用户
  28. await GetHubContext().Clients.Users(clientIds).LoginOut(message);
  29. }
  30. #region MyRegion
  31. /// <summary>
  32. /// 获取hubContext
  33. /// </summary>
  34. /// <returns></returns>
  35. private IHubContext<SimpleHub, ISimpleHub> GetHubContext()
  36. {
  37. //解析服务
  38. var service = App.GetService<IHubContext<SimpleHub, ISimpleHub>>();
  39. return service;
  40. }
  41. #endregion MyRegion
  42. }
  43. }