using Microsoft.AspNetCore.SignalR; namespace BPASmartClient.AgvApi { public class PersonHub : Hub { public override Task OnConnectedAsync() { Console.WriteLine($"{Context.ConnectionId}:= 连接成功"); Factory.GetInstance.HubCallerClient = Clients; return base.OnConnectedAsync(); } public override Task OnDisconnectedAsync(Exception? exception) { Console.WriteLine($"{Context.ConnectionId}:= 断开连接"); return base.OnDisconnectedAsync(exception); } /// /// 接收客户端发来的信息,并向客户端发送信息 /// /// /// public Task Send(object str) { return Clients.Caller.SendAsync("SendMessage", str); } } }