Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Janicki committed Aug 11, 2023
1 parent e939795 commit 47d49e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Consumer/RealTime/Models/HeartBeatTimes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public void Clear()
End = null;
}

public override string ToString() =>
public override string ToString() =>
$"Start: {GetText(Start)}, End: {GetText(End)}";

private static string GetText(DateTime? value) =>
private static string GetText(DateTime? value) =>
value is null ? "null" : value.Value.ToString("O");
}
10 changes: 8 additions & 2 deletions Consumer/RealTime/Services/RealTimeWebSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private async Task MonitorHandler(WebSocketState state, CancellationToken cancel
{
return response.AsT1;
}
_argument = new Argument(response.AsT0, _argument.ClientWebSocketWrapper, _defaultAdvice);
_argument = _argument.CreateWithClientIdAndAdvice(response.AsT0, _defaultAdvice);
await SendHeartbeat(_argument, tokenSources.LinkedTokenSourceToken).ConfigureAwait(false);
}
else
Expand Down Expand Up @@ -174,7 +174,7 @@ private async Task HeartBeatHandler(HeartbeatResponse response, CancellationToke
if (result.IsT0)
{
_logger.LogDebug("Get successful heartbeat results.");
_argument = new Argument(_argument!.ClientId, _argument.ClientWebSocketWrapper, result.AsT0);
_argument = _argument!.CreateWithAdvice(result.AsT0);
_heartBeatTimes.SetEnd();
await SendHeartbeat(_argument, cancellationToken).ConfigureAwait(false);
_fullReconnect = false;
Expand Down Expand Up @@ -370,5 +370,11 @@ public Argument(string clientId, IClientWebSocketWrapper clientWebSocketWrapper,
public IClientWebSocketWrapper ClientWebSocketWrapper { get; }

public Advice Advice { get; }

public Argument CreateWithAdvice(Advice advice) =>
new(ClientId, ClientWebSocketWrapper, advice);

public Argument CreateWithClientIdAndAdvice(string clientId, Advice advice) =>
new(clientId, ClientWebSocketWrapper, advice);
}
}

0 comments on commit 47d49e7

Please sign in to comment.