replace multiple hubs with one
This commit is contained in:
@@ -78,7 +78,7 @@ namespace MareSynchronos
|
||||
public Dictionary<string, Dictionary<string, string>> UidServerComments { get; set; } = new();
|
||||
|
||||
public Dictionary<string, string> UidComments { get; set; } = new();
|
||||
public int Version { get; set; } = 3;
|
||||
public int Version { get; set; } = 4;
|
||||
|
||||
public bool ShowTransferWindow { get; set; } = true;
|
||||
|
||||
@@ -157,6 +157,33 @@ namespace MareSynchronos
|
||||
Version = 3;
|
||||
Save();
|
||||
}
|
||||
|
||||
if (Version == 3)
|
||||
{
|
||||
Logger.Debug("Migrating Configuration from V3 to V4");
|
||||
|
||||
ApiUri = ApiUri.Replace("wss://v2202207178628194299.powersrv.de:6871", "wss://v2202207178628194299.powersrv.de:6872");
|
||||
foreach (var kvp in ClientSecret.ToList())
|
||||
{
|
||||
var newKey = kvp.Key.Replace("wss://v2202207178628194299.powersrv.de:6871", "wss://v2202207178628194299.powersrv.de:6872");
|
||||
ClientSecret.Remove(kvp.Key);
|
||||
if (ClientSecret.ContainsKey(newKey))
|
||||
{
|
||||
ClientSecret[newKey] = kvp.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClientSecret.Add(newKey, kvp.Value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var kvp in UidServerComments.ToList())
|
||||
{
|
||||
var newKey = kvp.Key.Replace("wss://v2202207178628194299.powersrv.de:6871", "wss://v2202207178628194299.powersrv.de:6872");
|
||||
UidServerComments.Remove(kvp.Key);
|
||||
UidServerComments.Add(newKey, kvp.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<Authors></Authors>
|
||||
<Company></Company>
|
||||
<Version>0.1.10.0</Version>
|
||||
<Version>0.1.11.0</Version>
|
||||
<Description></Description>
|
||||
<Copyright></Copyright>
|
||||
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>
|
||||
|
||||
@@ -23,19 +23,19 @@ namespace MareSynchronos.WebAPI
|
||||
{
|
||||
Logger.Warn("Cancelling upload");
|
||||
_uploadCancellationTokenSource?.Cancel();
|
||||
_fileHub!.SendAsync(FilesHubAPI.SendAbortUpload);
|
||||
_mareHub!.SendAsync(FilesHubAPI.SendAbortUpload);
|
||||
CurrentUploads.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DeleteAllMyFiles()
|
||||
{
|
||||
await _fileHub!.SendAsync(FilesHubAPI.SendDeleteAllFiles);
|
||||
await _mareHub!.SendAsync(FilesHubAPI.SendDeleteAllFiles);
|
||||
}
|
||||
|
||||
private async Task<string> DownloadFile(int downloadId, string hash, CancellationToken ct)
|
||||
{
|
||||
var reader = _fileHub!.StreamAsync<byte[]>(FilesHubAPI.StreamDownloadFileAsync, hash, ct);
|
||||
var reader = _mareHub!.StreamAsync<byte[]>(FilesHubAPI.StreamDownloadFileAsync, hash, ct);
|
||||
string fileName = Path.GetTempFileName();
|
||||
await using var fs = File.OpenWrite(fileName);
|
||||
await foreach (var data in reader.WithCancellation(ct))
|
||||
@@ -56,7 +56,7 @@ namespace MareSynchronos.WebAPI
|
||||
List<DownloadFileDto> downloadFileInfoFromService = new List<DownloadFileDto>();
|
||||
foreach (var file in fileReplacementDto)
|
||||
{
|
||||
downloadFileInfoFromService.Add(await _fileHub!.InvokeAsync<DownloadFileDto>(FilesHubAPI.InvokeGetFileSize, file.Hash, ct));
|
||||
downloadFileInfoFromService.Add(await _mareHub!.InvokeAsync<DownloadFileDto>(FilesHubAPI.InvokeGetFileSize, file.Hash, ct));
|
||||
}
|
||||
|
||||
CurrentDownloads[currentDownloadId] = downloadFileInfoFromService.Distinct().Select(d => new DownloadFileTransfer(d))
|
||||
@@ -128,7 +128,7 @@ namespace MareSynchronos.WebAPI
|
||||
var uploadToken = _uploadCancellationTokenSource.Token;
|
||||
Logger.Verbose("New Token Created");
|
||||
|
||||
var filesToUpload = await _fileHub!.InvokeAsync<List<UploadFileDto>>(FilesHubAPI.InvokeSendFiles, character.FileReplacements.Select(c => c.Hash).Distinct(), uploadToken);
|
||||
var filesToUpload = await _mareHub!.InvokeAsync<List<UploadFileDto>>(FilesHubAPI.InvokeSendFiles, character.FileReplacements.Select(c => c.Hash).Distinct(), uploadToken);
|
||||
|
||||
foreach (var file in filesToUpload.Where(f => !f.IsForbidden))
|
||||
{
|
||||
@@ -183,11 +183,11 @@ namespace MareSynchronos.WebAPI
|
||||
}
|
||||
|
||||
Logger.Verbose("Upload tasks complete, waiting for server to confirm");
|
||||
var anyUploadsOpen = await _fileHub!.InvokeAsync<bool>(FilesHubAPI.InvokeIsUploadFinished, uploadToken);
|
||||
var anyUploadsOpen = await _mareHub!.InvokeAsync<bool>(FilesHubAPI.InvokeIsUploadFinished, uploadToken);
|
||||
Logger.Verbose("Uploads open: " + anyUploadsOpen);
|
||||
while (anyUploadsOpen && !uploadToken.IsCancellationRequested)
|
||||
{
|
||||
anyUploadsOpen = await _fileHub!.InvokeAsync<bool>(FilesHubAPI.InvokeIsUploadFinished, uploadToken);
|
||||
anyUploadsOpen = await _mareHub!.InvokeAsync<bool>(FilesHubAPI.InvokeIsUploadFinished, uploadToken);
|
||||
await Task.Delay(TimeSpan.FromSeconds(0.5), uploadToken);
|
||||
Logger.Verbose("Waiting for uploads to finish");
|
||||
}
|
||||
@@ -197,7 +197,7 @@ namespace MareSynchronos.WebAPI
|
||||
if (!uploadToken.IsCancellationRequested)
|
||||
{
|
||||
Logger.Verbose("=== Pushing character data ===");
|
||||
await _userHub!.InvokeAsync(UserHubAPI.InvokePushCharacterDataToVisibleClients, character, visibleCharacterIds, uploadToken);
|
||||
await _mareHub!.InvokeAsync(UserHubAPI.InvokePushCharacterDataToVisibleClients, character, visibleCharacterIds, uploadToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -234,7 +234,7 @@ namespace MareSynchronos.WebAPI
|
||||
}
|
||||
}
|
||||
|
||||
await _fileHub!.SendAsync(FilesHubAPI.SendUploadFileStreamAsync, fileHash, AsyncFileData(uploadToken), uploadToken);
|
||||
await _mareHub!.SendAsync(FilesHubAPI.SendUploadFileStreamAsync, fileHash, AsyncFileData(uploadToken), uploadToken);
|
||||
}
|
||||
|
||||
public void CancelDownload(int downloadId)
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace MareSynchronos.WebAPI
|
||||
{
|
||||
_pluginConfiguration.ClientSecret.Remove(ApiUri);
|
||||
_pluginConfiguration.Save();
|
||||
await _fileHub!.SendAsync(FilesHubAPI.SendDeleteAllFiles);
|
||||
await _userHub!.SendAsync(UserHubAPI.SendDeleteAccount);
|
||||
await _mareHub!.SendAsync(FilesHubAPI.SendDeleteAllFiles);
|
||||
await _mareHub!.SendAsync(UserHubAPI.SendDeleteAccount);
|
||||
await CreateConnections();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace MareSynchronos.WebAPI
|
||||
{
|
||||
if (!ServerAlive) return;
|
||||
Logger.Debug("Registering at service " + ApiUri);
|
||||
var response = await _userHub!.InvokeAsync<string>(UserHubAPI.InvokeRegister);
|
||||
var response = await _mareHub!.InvokeAsync<string>(UserHubAPI.InvokeRegister);
|
||||
_pluginConfiguration.ClientSecret[ApiUri] = response;
|
||||
_pluginConfiguration.Save();
|
||||
if (!isIntroUi)
|
||||
@@ -35,25 +35,25 @@ namespace MareSynchronos.WebAPI
|
||||
|
||||
public async Task<List<string>> GetOnlineCharacters()
|
||||
{
|
||||
return await _userHub!.InvokeAsync<List<string>>(UserHubAPI.InvokeGetOnlineCharacters);
|
||||
return await _mareHub!.InvokeAsync<List<string>>(UserHubAPI.InvokeGetOnlineCharacters);
|
||||
}
|
||||
|
||||
public async Task SendPairedClientAddition(string uid)
|
||||
{
|
||||
if (!IsConnected || SecretKey == "-") return;
|
||||
await _userHub!.SendAsync(UserHubAPI.SendPairedClientAddition, uid);
|
||||
await _mareHub!.SendAsync(UserHubAPI.SendPairedClientAddition, uid);
|
||||
}
|
||||
|
||||
public async Task SendPairedClientPauseChange(string uid, bool paused)
|
||||
{
|
||||
if (!IsConnected || SecretKey == "-") return;
|
||||
await _userHub!.SendAsync(UserHubAPI.SendPairedClientPauseChange, uid, paused);
|
||||
await _mareHub!.SendAsync(UserHubAPI.SendPairedClientPauseChange, uid, paused);
|
||||
}
|
||||
|
||||
public async Task SendPairedClientRemoval(string uid)
|
||||
{
|
||||
if (!IsConnected || SecretKey == "-") return;
|
||||
await _userHub!.SendAsync(UserHubAPI.SendPairedClientRemoval, uid);
|
||||
await _mareHub!.SendAsync(UserHubAPI.SendPairedClientRemoval, uid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace MareSynchronos.WebAPI
|
||||
public partial class ApiController : IDisposable
|
||||
{
|
||||
public const string MainServer = "Lunae Crescere Incipientis (Central Server EU)";
|
||||
public const string MainServiceUri = "wss://v2202207178628194299.powersrv.de:6871";
|
||||
public const string MainServiceUri = "wss://v2202207178628194299.powersrv.de:6872";
|
||||
|
||||
public readonly int[] SupportedServerVersions = { API.API.Version };
|
||||
|
||||
@@ -38,15 +38,10 @@ namespace MareSynchronos.WebAPI
|
||||
|
||||
private CancellationTokenSource _connectionCancellationTokenSource;
|
||||
|
||||
private HubConnection? _fileHub;
|
||||
|
||||
private HubConnection? _connectionHub;
|
||||
|
||||
private HubConnection? _adminHub;
|
||||
private HubConnection? _mareHub;
|
||||
|
||||
private CancellationTokenSource? _uploadCancellationTokenSource;
|
||||
|
||||
private HubConnection? _userHub;
|
||||
private ConnectionDto? _connectionDto;
|
||||
public SystemInfoDto SystemInfoDto { get; private set; } = new();
|
||||
public bool IsModerator => (_connectionDto?.IsAdmin ?? false) || (_connectionDto?.IsModerator ?? false);
|
||||
@@ -71,7 +66,7 @@ namespace MareSynchronos.WebAPI
|
||||
|
||||
private void DalamudUtilOnLogOut()
|
||||
{
|
||||
Task.Run(async () => await StopAllConnections(_connectionCancellationTokenSource.Token));
|
||||
Task.Run(async () => await StopConnection(_connectionCancellationTokenSource.Token));
|
||||
}
|
||||
|
||||
private void DalamudUtilOnLogIn()
|
||||
@@ -119,7 +114,7 @@ namespace MareSynchronos.WebAPI
|
||||
: "-";
|
||||
|
||||
public bool ServerAlive =>
|
||||
(_connectionHub?.State ?? HubConnectionState.Disconnected) == HubConnectionState.Connected;
|
||||
(_mareHub?.State ?? HubConnectionState.Disconnected) == HubConnectionState.Connected;
|
||||
|
||||
public Dictionary<string, string> ServerDictionary => new Dictionary<string, string>()
|
||||
{ { MainServiceUri, MainServer } }
|
||||
@@ -155,14 +150,14 @@ namespace MareSynchronos.WebAPI
|
||||
{
|
||||
Logger.Verbose("Recreating Connection");
|
||||
|
||||
await StopAllConnections(_connectionCancellationTokenSource.Token);
|
||||
await StopConnection(_connectionCancellationTokenSource.Token);
|
||||
|
||||
_connectionCancellationTokenSource.Cancel();
|
||||
_connectionCancellationTokenSource = new CancellationTokenSource();
|
||||
var token = _connectionCancellationTokenSource.Token;
|
||||
while (ServerState is not ServerState.Connected && !token.IsCancellationRequested)
|
||||
{
|
||||
await StopAllConnections(token);
|
||||
await StopConnection(token);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -176,17 +171,11 @@ namespace MareSynchronos.WebAPI
|
||||
|
||||
if (token.IsCancellationRequested) break;
|
||||
|
||||
_connectionHub = BuildHubConnection(ConnectionHubAPI.Path);
|
||||
_userHub = BuildHubConnection(UserHubAPI.Path);
|
||||
_fileHub = BuildHubConnection(FilesHubAPI.Path);
|
||||
_adminHub = BuildHubConnection(AdminHubAPI.Path);
|
||||
_mareHub = BuildHubConnection(API.API.Path);
|
||||
|
||||
await _connectionHub.StartAsync(token);
|
||||
await _userHub.StartAsync(token);
|
||||
await _fileHub.StartAsync(token);
|
||||
await _adminHub.StartAsync(token);
|
||||
await _mareHub.StartAsync(token);
|
||||
|
||||
_connectionHub.On<SystemInfoDto>(ConnectionHubAPI.OnUpdateSystemInfo, (dto) => SystemInfoDto = dto);
|
||||
_mareHub.On<SystemInfoDto>(ConnectionHubAPI.OnUpdateSystemInfo, (dto) => SystemInfoDto = dto);
|
||||
|
||||
if (_pluginConfiguration.FullPause)
|
||||
{
|
||||
@@ -195,41 +184,41 @@ namespace MareSynchronos.WebAPI
|
||||
}
|
||||
|
||||
_connectionDto =
|
||||
await _connectionHub.InvokeAsync<ConnectionDto>(ConnectionHubAPI.InvokeHeartbeat, _dalamudUtil.PlayerNameHashed, token);
|
||||
await _mareHub.InvokeAsync<ConnectionDto>(ConnectionHubAPI.InvokeHeartbeat, _dalamudUtil.PlayerNameHashed, token);
|
||||
if (ServerState is ServerState.Connected) // user is authorized && server is legit
|
||||
{
|
||||
Logger.Debug("Initializing data");
|
||||
_userHub.On<ClientPairDto, string>(UserHubAPI.OnUpdateClientPairs,
|
||||
_mareHub.On<ClientPairDto, string>(UserHubAPI.OnUpdateClientPairs,
|
||||
UpdateLocalClientPairsCallback);
|
||||
_userHub.On<CharacterCacheDto, string>(UserHubAPI.OnReceiveCharacterData,
|
||||
_mareHub.On<CharacterCacheDto, string>(UserHubAPI.OnReceiveCharacterData,
|
||||
ReceiveCharacterDataCallback);
|
||||
_userHub.On<string>(UserHubAPI.OnRemoveOnlinePairedPlayer,
|
||||
_mareHub.On<string>(UserHubAPI.OnRemoveOnlinePairedPlayer,
|
||||
(s) => PairedClientOffline?.Invoke(s));
|
||||
_userHub.On<string>(UserHubAPI.OnAddOnlinePairedPlayer,
|
||||
_mareHub.On<string>(UserHubAPI.OnAddOnlinePairedPlayer,
|
||||
(s) => PairedClientOnline?.Invoke(s));
|
||||
_adminHub.On(AdminHubAPI.OnForcedReconnect, UserForcedReconnectCallback);
|
||||
_mareHub.On(AdminHubAPI.OnForcedReconnect, UserForcedReconnectCallback);
|
||||
|
||||
PairedClients =
|
||||
await _userHub!.InvokeAsync<List<ClientPairDto>>(UserHubAPI.InvokeGetPairedClients, token);
|
||||
await _mareHub!.InvokeAsync<List<ClientPairDto>>(UserHubAPI.InvokeGetPairedClients, token);
|
||||
|
||||
_connectionHub.Closed += ConnectionHubOnClosed;
|
||||
_connectionHub.Reconnected += ConnectionHubOnReconnected;
|
||||
_connectionHub.Reconnecting += ConnectionHubOnReconnecting;
|
||||
_mareHub.Closed += MareHubOnClosed;
|
||||
_mareHub.Reconnected += MareHubOnReconnected;
|
||||
_mareHub.Reconnecting += MareHubOnReconnecting;
|
||||
|
||||
if (IsModerator)
|
||||
{
|
||||
AdminForbiddenFiles =
|
||||
await _adminHub.InvokeAsync<List<ForbiddenFileDto>>(AdminHubAPI.InvokeGetForbiddenFiles,
|
||||
await _mareHub.InvokeAsync<List<ForbiddenFileDto>>(AdminHubAPI.InvokeGetForbiddenFiles,
|
||||
token);
|
||||
AdminBannedUsers =
|
||||
await _adminHub.InvokeAsync<List<BannedUserDto>>(AdminHubAPI.InvokeGetBannedUsers,
|
||||
await _mareHub.InvokeAsync<List<BannedUserDto>>(AdminHubAPI.InvokeGetBannedUsers,
|
||||
token);
|
||||
_adminHub.On<BannedUserDto>(AdminHubAPI.OnUpdateOrAddBannedUser,
|
||||
_mareHub.On<BannedUserDto>(AdminHubAPI.OnUpdateOrAddBannedUser,
|
||||
UpdateOrAddBannedUserCallback);
|
||||
_adminHub.On<BannedUserDto>(AdminHubAPI.OnDeleteBannedUser, DeleteBannedUserCallback);
|
||||
_adminHub.On<ForbiddenFileDto>(AdminHubAPI.OnUpdateOrAddForbiddenFile,
|
||||
_mareHub.On<BannedUserDto>(AdminHubAPI.OnDeleteBannedUser, DeleteBannedUserCallback);
|
||||
_mareHub.On<ForbiddenFileDto>(AdminHubAPI.OnUpdateOrAddForbiddenFile,
|
||||
UpdateOrAddForbiddenFileCallback);
|
||||
_adminHub.On<ForbiddenFileDto>(AdminHubAPI.OnDeleteForbiddenFile,
|
||||
_mareHub.On<ForbiddenFileDto>(AdminHubAPI.OnDeleteForbiddenFile,
|
||||
DeleteForbiddenFileCallback);
|
||||
}
|
||||
|
||||
@@ -245,7 +234,7 @@ namespace MareSynchronos.WebAPI
|
||||
Logger.Warn(ex.Message);
|
||||
Logger.Warn(ex.StackTrace ?? string.Empty);
|
||||
Logger.Debug("Failed to establish connection, retrying");
|
||||
await StopAllConnections(token);
|
||||
await StopConnection(token);
|
||||
await Task.Delay(TimeSpan.FromSeconds(new Random().Next(5, 20)), token);
|
||||
}
|
||||
}
|
||||
@@ -258,7 +247,7 @@ namespace MareSynchronos.WebAPI
|
||||
_dalamudUtil.LogIn -= DalamudUtilOnLogIn;
|
||||
_dalamudUtil.LogOut -= DalamudUtilOnLogOut;
|
||||
|
||||
Task.Run(async () => await StopAllConnections(_connectionCancellationTokenSource.Token));
|
||||
Task.Run(async () => await StopConnection(_connectionCancellationTokenSource.Token));
|
||||
_connectionCancellationTokenSource?.Cancel();
|
||||
}
|
||||
|
||||
@@ -278,7 +267,7 @@ namespace MareSynchronos.WebAPI
|
||||
.Build();
|
||||
}
|
||||
|
||||
private Task ConnectionHubOnClosed(Exception? arg)
|
||||
private Task MareHubOnClosed(Exception? arg)
|
||||
{
|
||||
CurrentUploads.Clear();
|
||||
CurrentDownloads.Clear();
|
||||
@@ -288,15 +277,15 @@ namespace MareSynchronos.WebAPI
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task ConnectionHubOnReconnected(string? arg)
|
||||
private async Task MareHubOnReconnected(string? arg)
|
||||
{
|
||||
Logger.Debug("Connection restored");
|
||||
await Task.Delay(TimeSpan.FromSeconds(new Random().Next(5, 10)));
|
||||
_connectionDto = await _connectionHub!.InvokeAsync<ConnectionDto>(ConnectionHubAPI.InvokeHeartbeat, _dalamudUtil.PlayerNameHashed);
|
||||
_connectionDto = await _mareHub!.InvokeAsync<ConnectionDto>(ConnectionHubAPI.InvokeHeartbeat, _dalamudUtil.PlayerNameHashed);
|
||||
Connected?.Invoke();
|
||||
}
|
||||
|
||||
private Task ConnectionHubOnReconnecting(Exception? arg)
|
||||
private Task MareHubOnReconnecting(Exception? arg)
|
||||
{
|
||||
CurrentUploads.Clear();
|
||||
CurrentDownloads.Clear();
|
||||
@@ -306,38 +295,17 @@ namespace MareSynchronos.WebAPI
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task StopAllConnections(CancellationToken token)
|
||||
private async Task StopConnection(CancellationToken token)
|
||||
{
|
||||
Logger.Verbose("Stopping all connections");
|
||||
if (_connectionHub is not null)
|
||||
if (_mareHub is not null)
|
||||
{
|
||||
await _connectionHub.StopAsync(token);
|
||||
_connectionHub.Closed -= ConnectionHubOnClosed;
|
||||
_connectionHub.Reconnected -= ConnectionHubOnReconnected;
|
||||
_connectionHub.Reconnecting += ConnectionHubOnReconnecting;
|
||||
await _connectionHub.DisposeAsync();
|
||||
_connectionHub = null;
|
||||
}
|
||||
|
||||
if (_fileHub is not null)
|
||||
{
|
||||
await _fileHub.StopAsync(token);
|
||||
await _fileHub.DisposeAsync();
|
||||
_fileHub = null;
|
||||
}
|
||||
|
||||
if (_userHub is not null)
|
||||
{
|
||||
await _userHub.StopAsync(token);
|
||||
await _userHub.DisposeAsync();
|
||||
_userHub = null;
|
||||
}
|
||||
|
||||
if (_adminHub is not null)
|
||||
{
|
||||
await _adminHub.StopAsync(token);
|
||||
await _adminHub.DisposeAsync();
|
||||
_adminHub = null;
|
||||
await _mareHub.StopAsync(token);
|
||||
_mareHub.Closed -= MareHubOnClosed;
|
||||
_mareHub.Reconnected -= MareHubOnReconnected;
|
||||
_mareHub.Reconnecting += MareHubOnReconnecting;
|
||||
await _mareHub.DisposeAsync();
|
||||
_mareHub = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,39 +9,39 @@ namespace MareSynchronos.WebAPI
|
||||
{
|
||||
public async Task AddOrUpdateForbiddenFileEntry(ForbiddenFileDto forbiddenFile)
|
||||
{
|
||||
await _adminHub!.SendAsync(AdminHubAPI.SendUpdateOrAddForbiddenFile, forbiddenFile);
|
||||
await _mareHub!.SendAsync(AdminHubAPI.SendUpdateOrAddForbiddenFile, forbiddenFile);
|
||||
}
|
||||
|
||||
public async Task DeleteForbiddenFileEntry(ForbiddenFileDto forbiddenFile)
|
||||
{
|
||||
await _adminHub!.SendAsync(AdminHubAPI.SendDeleteForbiddenFile, forbiddenFile);
|
||||
await _mareHub!.SendAsync(AdminHubAPI.SendDeleteForbiddenFile, forbiddenFile);
|
||||
}
|
||||
|
||||
public async Task AddOrUpdateBannedUserEntry(BannedUserDto bannedUser)
|
||||
{
|
||||
await _adminHub!.SendAsync(AdminHubAPI.SendUpdateOrAddBannedUser, bannedUser);
|
||||
await _mareHub!.SendAsync(AdminHubAPI.SendUpdateOrAddBannedUser, bannedUser);
|
||||
}
|
||||
|
||||
public async Task DeleteBannedUserEntry(BannedUserDto bannedUser)
|
||||
{
|
||||
await _adminHub!.SendAsync(AdminHubAPI.SendDeleteBannedUser, bannedUser);
|
||||
await _mareHub!.SendAsync(AdminHubAPI.SendDeleteBannedUser, bannedUser);
|
||||
}
|
||||
|
||||
public async Task RefreshOnlineUsers()
|
||||
{
|
||||
AdminOnlineUsers = await _adminHub!.InvokeAsync<List<OnlineUserDto>>(AdminHubAPI.InvokeGetOnlineUsers);
|
||||
AdminOnlineUsers = await _mareHub!.InvokeAsync<List<OnlineUserDto>>(AdminHubAPI.InvokeGetOnlineUsers);
|
||||
}
|
||||
|
||||
public List<OnlineUserDto> AdminOnlineUsers { get; set; } = new List<OnlineUserDto>();
|
||||
|
||||
public void PromoteToModerator(string onlineUserUID)
|
||||
{
|
||||
_adminHub!.SendAsync(AdminHubAPI.SendChangeModeratorStatus, onlineUserUID, true);
|
||||
_mareHub!.SendAsync(AdminHubAPI.SendChangeModeratorStatus, onlineUserUID, true);
|
||||
}
|
||||
|
||||
public void DemoteFromModerator(string onlineUserUID)
|
||||
{
|
||||
_adminHub!.SendAsync(AdminHubAPI.SendChangeModeratorStatus, onlineUserUID, false);
|
||||
_mareHub!.SendAsync(AdminHubAPI.SendChangeModeratorStatus, onlineUserUID, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user