Add Extra Logs For Status
Make Number Game Easier Remove Endpoint `users-online`
This commit is contained in:
parent
abaa850016
commit
8dcd38cc83
@ -57,14 +57,6 @@ namespace qtc_api.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("users-online")]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<ServiceResponse<List<UserInformationDto>>>> GetAllOnlineUsers()
|
||||
{
|
||||
var users = await _userService.GetAllOnlineUsers();
|
||||
return Ok(users);
|
||||
}
|
||||
|
||||
[HttpPut("update")]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<ServiceResponse<UserInformationDto>>> UpdateUserInformation(UserUpdateInformationDto user)
|
||||
@ -80,10 +72,6 @@ namespace qtc_api.Controllers
|
||||
{
|
||||
var updatedUser = await _userService.UpdateUserInfo(user);
|
||||
|
||||
// always try to overwrite cache when updating user info
|
||||
string recordId = $"User_{user.Id}_{DateTime.Now.ToString("yyyyMMdd_hhmm")}";
|
||||
await cache.SetRecordAsync(recordId, updatedUser);
|
||||
|
||||
return Ok(updatedUser);
|
||||
} else
|
||||
{
|
||||
|
@ -7,8 +7,8 @@ namespace qtc_api.Hubs
|
||||
{
|
||||
private IUserService _userService;
|
||||
private ILogger<ChatHub> _logger;
|
||||
private static List<UserConnectionDto> ConnectedUsers = new List<UserConnectionDto>();
|
||||
private static List<User> OnlineUsers = new List<User>();
|
||||
private static List<UserConnectionDto> ConnectedUsers = new();
|
||||
private static List<User> OnlineUsers = new();
|
||||
|
||||
private static Dictionary<string, List<User>> GroupUsers = new();
|
||||
|
||||
@ -32,7 +32,7 @@ namespace qtc_api.Hubs
|
||||
{
|
||||
ConnectedUsers.Remove(connection);
|
||||
OnlineUsers.Remove(user);
|
||||
await LogoutAsync(user!);
|
||||
await LogoutAsync(user);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,6 +64,8 @@ namespace qtc_api.Hubs
|
||||
{
|
||||
var statusDto = new UserStatusDto { Id = user.Id, Status = status };
|
||||
|
||||
Log($"Updating Status\n{JsonSerializer.Serialize(statusDto)}");
|
||||
|
||||
await _userService.UpdateStatus(statusDto);
|
||||
|
||||
await Clients.All.SendAsync("RefreshUserLists");
|
||||
@ -167,9 +169,7 @@ namespace qtc_api.Hubs
|
||||
|
||||
private async Task LoginAsync(User user)
|
||||
{
|
||||
var statusDto = new UserStatusDto { Id = user.Id, Status = 1 };
|
||||
|
||||
await _userService.UpdateStatus(statusDto);
|
||||
await UpdateStatusAsync(user, 1);
|
||||
|
||||
ServerConfig serverConfig = JsonDocument.Parse(File.ReadAllText("./ServerConfig.json")).Deserialize<ServerConfig>();
|
||||
|
||||
@ -181,9 +181,7 @@ namespace qtc_api.Hubs
|
||||
|
||||
private async Task LogoutAsync(User user)
|
||||
{
|
||||
var statusDto = new UserStatusDto { Id = user.Id, Status = 0 };
|
||||
|
||||
await _userService.UpdateStatus(statusDto);
|
||||
await UpdateStatusAsync(user, 0);
|
||||
await Clients.All.SendAsync("RefreshUserLists");
|
||||
|
||||
Log($"User {user.Username} Has Logged Out");
|
||||
|
@ -91,7 +91,7 @@ namespace qtc_api.Services.CurrencyGamesService
|
||||
public ServiceResponse<int> GetRandomNumber()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
return new ServiceResponse<int> { Success = true, Data = rnd.Next(1, 500) };
|
||||
return new ServiceResponse<int> { Success = true, Data = rnd.Next(1, 100) };
|
||||
}
|
||||
|
||||
public ServiceResponse<NumberGuessResult> GuessRandomNumber(int original, int guess)
|
||||
|
Loading…
x
Reference in New Issue
Block a user