Church.Net.API/WebAPI/Hubs/WhoIsSpyHub.cs
2022-09-08 08:04:32 -07:00

38 lines
1001 B
C#

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebAPI.Hubs
{
public class WhoIsSpyHub:Hub
{
private readonly GameRoomLogic gameRoomLogic;
public WhoIsSpyHub(GameRoomLogic gameRoomLogic)
{
this.gameRoomLogic = gameRoomLogic;
}
public async Task JoinGame(string clientId,string username)
{
await Clients.All.SendAsync("JoinGame", clientId, username);
}
public override Task OnConnectedAsync()
{
var username = Context.GetHttpContext().Request.Query["username"];
return base.OnConnectedAsync();
}
public override Task OnDisconnectedAsync(Exception exception)
{
var username = Context.GetHttpContext().Request.Query["username"];
return base.OnDisconnectedAsync(exception);
}
}
}