From 331cb612adeed2612ff0d8d3af65dc650c179343 Mon Sep 17 00:00:00 2001 From: SirConstance Date: Sun, 28 Sep 2025 22:32:05 +0200 Subject: [PATCH] =?UTF-8?q?Pr=C3=A9paration=20serveur=20pour=20TypingState?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MareAPI | 2 +- .../Hubs/MareHub.ClientStubs.cs | 2 + .../Hubs/MareHub.Typing.cs | 40 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Typing.cs diff --git a/MareAPI b/MareAPI index fa9b7bc..3b17590 160000 --- a/MareAPI +++ b/MareAPI @@ -1 +1 @@ -Subproject commit fa9b7bce43b8baf9ba17d9e1df221fafa20fd6d7 +Subproject commit 3b175900c10a9a152a168b1bd6fee390aa58e8e0 diff --git a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.ClientStubs.cs b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.ClientStubs.cs index 29d64e5..721950b 100644 --- a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.ClientStubs.cs +++ b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.ClientStubs.cs @@ -54,6 +54,8 @@ namespace MareSynchronosServer.Hubs public Task Client_UserUpdateSelfPairPermissions(UserPermissionsDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + public Task Client_UserTypingState(TypingStateDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + public Task Client_GposeLobbyJoin(UserData userData) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); public Task Client_GposeLobbyLeave(UserData userData) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); public Task Client_GposeLobbyPushCharacterData(CharaDataDownloadDto charaDownloadDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); diff --git a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Typing.cs b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Typing.cs new file mode 100644 index 0000000..82ef1e3 --- /dev/null +++ b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Typing.cs @@ -0,0 +1,40 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using MareSynchronos.API.Data.Extensions; +using MareSynchronos.API.Dto.User; +using MareSynchronosServer.Utils; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; + +namespace MareSynchronosServer.Hubs; + +public partial class MareHub +{ + [Authorize(Policy = "Identified")] + public async Task UserSetTypingState(bool isTyping) + { + _logger.LogCallInfo(MareHubLogger.Args(isTyping)); + + var pairedEntries = await GetAllPairedClientsWithPauseState().ConfigureAwait(false); + if (pairedEntries.Count == 0) + return; + + var recipients = pairedEntries + .Where(p => !p.IsPaused) + .Select(p => p.UID) + .Distinct(StringComparer.Ordinal) + .ToList(); + + if (recipients.Count == 0) + return; + + var sender = await DbContext.Users.AsNoTracking() + .SingleAsync(u => u.UID == UserUID) + .ConfigureAwait(false); + + var typingDto = new TypingStateDto(sender.ToUserData(), isTyping); + + await Clients.Users(recipients).Client_UserTypingState(typingDto).ConfigureAwait(false); + } +}