do not publish twice on reconnect

This commit is contained in:
rootdarkarchon
2024-01-21 03:15:37 +01:00
committed by Loporrit
parent 3cda45a5fc
commit e4e858b927

View File

@@ -255,10 +255,10 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
return Task.CompletedTask;
}
public async Task<ConnectionDto> GetConnectionDto()
public async Task<ConnectionDto> GetConnectionDto(bool publishConnected = true)
{
var dto = await _mareHub!.InvokeAsync<ConnectionDto>(nameof(GetConnectionDto)).ConfigureAwait(false);
Mediator.Publish(new ConnectedMessage(dto));
if (publishConnected) Mediator.Publish(new ConnectedMessage(dto));
return dto;
}
@@ -381,7 +381,7 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IM
try
{
InitializeApiHooks();
_connectionDto = await GetConnectionDto().ConfigureAwait(false);
_connectionDto = await GetConnectionDto(publishConnected: false).ConfigureAwait(false);
if (_connectionDto.ServerVersion != IMareHub.ApiVersion)
{
await StopConnection(ServerState.VersionMisMatch).ConfigureAwait(false);