55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using CommonDomain.Enum;
|
|
using FishRoomService.RoomService;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using RedisService;
|
|
|
|
namespace FishRoomService.Hubs
|
|
{
|
|
public class FishRoomHub : Hub
|
|
{
|
|
private readonly IRedisService _redisService;
|
|
private readonly IFishingRoomService _fishingRoomService;
|
|
|
|
public FishRoomHub(IRedisService redisService, IFishingRoomService fishingRoomService)
|
|
{
|
|
_redisService = redisService;
|
|
_fishingRoomService = fishingRoomService;
|
|
|
|
}
|
|
|
|
public override async Task OnConnectedAsync()
|
|
{
|
|
await base.OnConnectedAsync();
|
|
}
|
|
|
|
public override async Task OnDisconnectedAsync(Exception? exception)
|
|
{
|
|
await base.OnDisconnectedAsync(exception);
|
|
}
|
|
|
|
|
|
|
|
public async Task GetRoomList(string userId, GameTypeEnum gameType, int roomLevel, int roomPartition)
|
|
{
|
|
string cid = Context.ConnectionId;
|
|
|
|
await _fishingRoomService.GetRoomList(cid, userId, gameType, roomLevel, roomPartition);
|
|
|
|
}
|
|
|
|
public async Task GetRoomInfo(string roomId)
|
|
{
|
|
string cid = Context.ConnectionId;
|
|
var room = _redisService.GetGameRoom(roomId);
|
|
|
|
await Clients.Caller.SendAsync("GetRoomInfoResult", room);
|
|
|
|
}
|
|
}
|
|
}
|