From 4633b82772bb625e554b87b16eaef46ab77e5949 Mon Sep 17 00:00:00 2001 From: Benedikt Schenkel Date: Mon, 18 Dec 2023 12:06:41 +0100 Subject: [PATCH] remove connection timeout --- .../PointToInterlockingConnection.cs | 12 ++---------- .../PointToInterlockingConnection.cs | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/FieldElementSubsystems/Connections/EulynxBaseline4R1/PointToInterlockingConnection.cs b/src/FieldElementSubsystems/Connections/EulynxBaseline4R1/PointToInterlockingConnection.cs index 1ad4b22..c9110dd 100644 --- a/src/FieldElementSubsystems/Connections/EulynxBaseline4R1/PointToInterlockingConnection.cs +++ b/src/FieldElementSubsystems/Connections/EulynxBaseline4R1/PointToInterlockingConnection.cs @@ -52,7 +52,7 @@ public void Connect(IConnection connection) public async Task InitializeConnection(GenericPointState state, bool observeAbilityToMove, CancellationToken cancellationToken) { - if (await ReceiveMessageWithTimeout(cancellationToken) == null) + if (await ReceiveMessage(cancellationToken) == null) { _logger.LogError("Unexpected message."); return false; @@ -61,7 +61,7 @@ public async Task InitializeConnection(GenericPointState state, bool obser var versionCheckResponse = new PointPdiVersionCheckMessage(_localId, _remoteId, PointPdiVersionCheckMessageResultPdiVersionCheck.PDIVersionsFromReceiverAndSenderDoMatch, /* TODO */ 0, 0, Array.Empty()); await SendMessage(versionCheckResponse); - if (await ReceiveMessageWithTimeout(cancellationToken) == null) + if (await ReceiveMessage(cancellationToken) == null) { _logger.LogError("Unexpected message."); return false; @@ -123,14 +123,6 @@ private async Task SendMessage(byte[] message) await CurrentConnection.SendAsync(message); } - private async Task ReceiveMessageWithTimeout(CancellationToken cancellationToken) where T : Message - { - if (CurrentConnection == null) throw new InvalidOperationException("Connection is null. Did you call Connect()?"); - ResetTimeout(); - var token = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _timeout.Token).Token; - return await ReceiveMessage(token); - } - private async Task ReceiveMessage(CancellationToken cancellationToken) where T : Message { if (CurrentConnection == null) throw new InvalidOperationException("Connection is null. Did you call Connect()?"); diff --git a/src/FieldElementSubsystems/Connections/EulynxBaseline4R2/PointToInterlockingConnection.cs b/src/FieldElementSubsystems/Connections/EulynxBaseline4R2/PointToInterlockingConnection.cs index d9da7ea..d401ff7 100644 --- a/src/FieldElementSubsystems/Connections/EulynxBaseline4R2/PointToInterlockingConnection.cs +++ b/src/FieldElementSubsystems/Connections/EulynxBaseline4R2/PointToInterlockingConnection.cs @@ -51,7 +51,7 @@ public void Connect(IConnection connection) public async Task InitializeConnection(GenericPointState state, bool observeAbilityToMove, CancellationToken cancellationToken) { - if (await ReceiveMessageWithTimeout(cancellationToken) == null) + if (await ReceiveMessage(cancellationToken) == null) { _logger.LogError("Unexpected message."); return false; @@ -60,7 +60,7 @@ public async Task InitializeConnection(GenericPointState state, bool obser var versionCheckResponse = new PointPdiVersionCheckMessage(_localId, _remoteId, PointPdiVersionCheckMessageResultPdiVersionCheck.PDIVersionsFromReceiverAndSenderDoMatch, /* TODO */ 0, 0, new byte[] { }); await SendMessage(versionCheckResponse); - if (await ReceiveMessageWithTimeout(cancellationToken) == null) + if (await ReceiveMessage(cancellationToken) == null) { _logger.LogError("Unexpected message."); return false; @@ -122,14 +122,6 @@ private async Task SendMessage(byte[] message) await CurrentConnection.SendAsync(message); } - private async Task ReceiveMessageWithTimeout(CancellationToken cancellationToken) where T : Message - { - if (CurrentConnection == null) throw new InvalidOperationException("Connection is null. Did you call Connect()?"); - ResetTimeout(); - var token = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _timeout.Token).Token; - return await ReceiveMessage(token); - } - private async Task ReceiveMessage(CancellationToken cancellationToken) where T : Message { if (CurrentConnection == null) throw new InvalidOperationException("Connection is null. Did you call Connect()?");