终端一体化运控平台
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

38 行
957 B

  1. using Microsoft.AspNetCore.SignalR;
  2. namespace BPASmartClient.AgvApi
  3. {
  4. /// <summary>
  5. /// 服务端
  6. /// </summary>
  7. public class PersonHub : Hub
  8. {
  9. public override Task OnConnectedAsync()
  10. {
  11. Console.WriteLine($"{Context.ConnectionId}:= 连接成功");
  12. Factory.GetInstance.HubCallerClient = Clients;
  13. return base.OnConnectedAsync();
  14. }
  15. public override Task OnDisconnectedAsync(Exception? exception)
  16. {
  17. Console.WriteLine($"{Context.ConnectionId}:= 断开连接");
  18. return base.OnDisconnectedAsync(exception);
  19. }
  20. /// <summary>
  21. /// 接收客户端发来的信息,并向客户端发送信息
  22. /// </summary>
  23. /// <param name="str"></param>
  24. /// <returns></returns>
  25. public Task Send(object str)
  26. {
  27. return Clients.Caller.SendAsync("SendMessage", str);
  28. }
  29. }
  30. }