Skip to content

Commit

Permalink
Log incoming and outgoing messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rs22 committed Jan 15, 2024
1 parent 5da74bb commit fa003cd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public async Task<GenericPointPosition> ReceiveMovePointCommand(CancellationToke

private async Task SendMessage(Message message)
{
_logger.LogInformation("Sending SCI message: {}", message);
await SendMessage(message.ToByteArray());
}

Expand All @@ -170,6 +171,7 @@ private async Task<T> ReceiveMessage<T>(CancellationToken cancellationToken) whe
if (CurrentConnection == null) throw new InvalidOperationException("Connection is null. Did you call Connect()?");

var message = Message.FromBytes(await CurrentConnection.ReceiveAsync(cancellationToken));
_logger.LogInformation("Received SCI message: {}", message);
if (message is T tMessage) return tMessage;
_logger.LogError("Unexpected message: {}", message);
throw new InvalidOperationException("Unexpected message.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public async Task<GenericPointPosition> ReceiveMovePointCommand(CancellationToke

private async Task SendMessage(Message message)
{
_logger.LogInformation("Sending SCI message: {}", message);
await SendMessage(message.ToByteArray());
}

Expand All @@ -170,6 +171,7 @@ private async Task<T> ReceiveMessage<T>(CancellationToken cancellationToken) whe
if (CurrentConnection == null) throw new InvalidOperationException("Connection is null. Did you call Connect()?");

var message = Message.FromBytes(await CurrentConnection.ReceiveAsync(cancellationToken));
_logger.LogInformation("Received SCI message: {}", message);
if (message is T tMessage) return tMessage;
_logger.LogError("Unexpected message: {}", message);
throw new InvalidOperationException("Unexpected message.");
Expand Down
3 changes: 0 additions & 3 deletions src/Point/Connections/GrpcConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ namespace EulynxLive.Point.Connections;
class GrpcConnection : IConnection
{
readonly AsyncDuplexStreamingCall<SciPacket, SciPacket>? _connection;
private readonly CancellationToken _stoppingToken;

public GrpcConnection(Metadata? metadata, string remoteEndpoint, CancellationToken stoppingToken)
{
_stoppingToken = stoppingToken;

var channel = GrpcChannel.ForAddress(remoteEndpoint);
var client = new RastaClient(channel);
_connection = client.Stream(metadata, cancellationToken: stoppingToken);
Expand Down

0 comments on commit fa003cd

Please sign in to comment.