Préparation serveur pour TypingState
This commit is contained in:
2
MareAPI
2
MareAPI
Submodule MareAPI updated: fa9b7bce43...3b175900c1
@@ -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_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_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_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_GposeLobbyPushCharacterData(CharaDataDownloadDto charaDownloadDto) => throw new PlatformNotSupportedException("Calling clientside method on server not supported");
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user