add(tools):添加signalR调试工具
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using IM_API.Interface.Services;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace IM_API.Hubs
|
||||
{
|
||||
public class ChatHub:Hub
|
||||
{
|
||||
private IJWTService _JWTService;
|
||||
public ChatHub(IJWTService jWTService)
|
||||
{
|
||||
_JWTService = jWTService;
|
||||
}
|
||||
|
||||
public override Task OnConnectedAsync()
|
||||
{
|
||||
var userIdStr = Context.User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
int userId = int.Parse(userIdStr);
|
||||
Console.WriteLine(userId);
|
||||
return base.OnConnectedAsync();
|
||||
}
|
||||
public async Task SendMessage(string user,string message)
|
||||
{
|
||||
await Clients.Caller.SendAsync("ReceiveMessage", "qwfqwfqw","test");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user