forked from AcaMate/AcaMate_API
[✨] SignalR 기능 활용한 채팅 기능 추가 중
This commit is contained in:
parent
7f9811e1a3
commit
2b37dc2746
|
@ -1,15 +1,14 @@
|
|||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace Back.Program.Common.Chat
|
||||
namespace Back.Program.Common.Chat;
|
||||
|
||||
public class ChatHub : Hub
|
||||
{
|
||||
public class ChatHub : Hub
|
||||
{
|
||||
// 클라이언트에서 메시지를 보내면 모든 사용자에게 전송
|
||||
public async Task SendMessage(string user, string message)
|
||||
{
|
||||
Console.WriteLine($"Message received: {user}: {message}");
|
||||
await Clients.All.SendAsync("ReceiveMessage", user, message);
|
||||
|
||||
}
|
||||
|
||||
// 특정 사용자에게 메시지를 보냄
|
||||
|
@ -33,10 +32,15 @@ namespace Back.Program.Common.Chat
|
|||
Console.WriteLine("OnDisconnectedAsync");
|
||||
await base.OnDisconnectedAsync(exception);
|
||||
}
|
||||
|
||||
|
||||
public async Task JoinRoom(string cid)
|
||||
{
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, cid);
|
||||
}
|
||||
|
||||
public async Task JoinGroup(string cid, string groupName)
|
||||
{
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, groupName);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
|
||||
*/
|
6
Program/Controllers/V1/ChatController.cs
Normal file
6
Program/Controllers/V1/ChatController.cs
Normal file
|
@ -0,0 +1,6 @@
|
|||
namespace Back.Program.Controllers.V1;
|
||||
|
||||
public class ChatController
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user