diff --git a/MareAPI b/MareAPI index fa9b7bc..114ecef 160000 --- a/MareAPI +++ b/MareAPI @@ -1 +1 @@ -Subproject commit fa9b7bce43b8baf9ba17d9e1df221fafa20fd6d7 +Subproject commit 114ecefac8ef36d80708134a450acb4172b9ace2 diff --git a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.ClientStubs.cs b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.ClientStubs.cs new file mode 100644 index 0000000..f83f9d5 --- /dev/null +++ b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.ClientStubs.cs @@ -0,0 +1,63 @@ +using MareSynchronos.API.Data; +using MareSynchronos.API.Data.Enum; +using MareSynchronos.API.Dto; +using MareSynchronos.API.Dto.CharaData; +using MareSynchronos.API.Dto.Chat; +using MareSynchronos.API.Dto.Group; +using MareSynchronos.API.Dto.User; + +namespace MareSynchronosServer.Hubs +{ + public partial class MareHub + { + public Task Client_DownloadReady(Guid requestId) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_GroupChangePermissions(GroupPermissionDto groupPermission) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_GroupChatMsg(GroupChatMsgDto groupChatMsgDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_GroupDelete(GroupDto groupDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_GroupPairChangePermissions(GroupPairUserPermissionDto permissionDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_GroupPairChangeUserInfo(GroupPairUserInfoDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_GroupPairJoined(GroupPairFullInfoDto groupPairInfoDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_GroupPairLeft(GroupPairDto groupPairDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_GroupSendFullInfo(GroupFullInfoDto groupInfo) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_GroupSendInfo(GroupInfoDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_ReceiveServerMessage(MessageSeverity messageSeverity, string message) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_UpdateSystemInfo(SystemInfoDto systemInfo) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_UserAddClientPair(UserPairDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_UserChatMsg(UserChatMsgDto userChatMsgDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_UserReceiveCharacterData(OnlineUserCharaDataDto dataDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_UserReceiveUploadStatus(UserDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_UserRemoveClientPair(UserDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_UserSendOffline(UserDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_UserSendOnline(OnlineUserIdentDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_UserUpdateOtherPairPermissions(UserPermissionsDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + public Task Client_UserUpdateProfile(UserDto dto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + + 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"); + public Task Client_GposeLobbyPushPoseData(UserData userData, PoseData poseData) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + public Task Client_GposeLobbyPushWorldData(UserData userData, WorldData worldData) => throw new PlatformNotSupportedException("Calling clientside method on server not supported"); + } +} \ No newline at end of file diff --git a/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Typing.cs b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Typing.cs new file mode 100644 index 0000000..6ff0bb6 --- /dev/null +++ b/MareSynchronosServer/MareSynchronosServer/Hubs/MareHub.Typing.cs @@ -0,0 +1,39 @@ +using System; +using System.Linq; +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); + } +} \ No newline at end of file