38 lines
1001 B
C#
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);
|
|
}
|
|
}
|
|
}
|