From 61f91f8ecbf4ae9b54a02862b6568ccd7618d9f8 Mon Sep 17 00:00:00 2001 From: Elad Zelingher Date: Sat, 19 Dec 2020 00:26:18 -0500 Subject: [PATCH 1/7] Adding CancellationToken support to Channel.Open --- .../WebSocket4Net/WebSocket4NetConnection.cs | 3 ++- .../RawSocket/Handshaker.cs | 20 +++++++++++++++---- .../RawSocket/NetworkStreamExtensions.cs | 19 +++++++++++++----- .../RawSocket/RawSocketClientConnection.cs | 15 +++++++------- .../ControlledBinaryWebSocketConnection.cs | 5 +++-- .../ControlledTextWebSocketConnection.cs | 5 +++-- .../WebSockets/WebSocketWrapperConnection.cs | 8 ++++---- .../Integration/MockConnectionListener.cs | 7 ++++--- .../MockConnection.cs | 3 ++- .../TestHelpers/Integration/WampPlayground.cs | 3 ++- .../WampPlaygroundRoleExtensions.cs | 1 + .../Tests/WampSharp.Tests/MockListener.cs | 3 ++- .../WAMP1/V1/Api/Client/IWampChannel.cs | 11 +++++++++- .../WAMP1/V1/Api/Client/WampChannel.cs | 7 ++++--- .../Connections/IControlledWampConnection.cs | 5 ++++- .../Connections/ReviveClientConnection.cs | 5 +++-- .../WAMP2/V2/Api/Client/IWampChannel.cs | 13 ++++++++++-- .../ServiceHostedRealmContainer.cs | 3 ++- .../WampSharp/WAMP2/V2/Client/WampChannel.cs | 4 ++-- .../V2/Fluent/ScheduledWampConnection.cs | 5 +++-- .../InMemory/InMemoryConnectionListener.cs | 3 ++- 21 files changed, 102 insertions(+), 46 deletions(-) diff --git a/src/netstandard/Default/WampSharp.WebSocket4Net/WebSocket4Net/WebSocket4NetConnection.cs b/src/netstandard/Default/WampSharp.WebSocket4Net/WebSocket4Net/WebSocket4NetConnection.cs index cd89dca7e..821b51ef8 100644 --- a/src/netstandard/Default/WampSharp.WebSocket4Net/WebSocket4Net/WebSocket4NetConnection.cs +++ b/src/netstandard/Default/WampSharp.WebSocket4Net/WebSocket4Net/WebSocket4NetConnection.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using SuperSocket.ClientEngine; using WampSharp.Core.Listener; using WampSharp.Core.Message; @@ -67,7 +68,7 @@ private void WebSocketOnError(object sender, ErrorEventArgs e) RaiseConnectionError(e.Exception); } - public void Connect() + public void Connect(CancellationToken cancellationToken) { mWebSocket.Open(); } diff --git a/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/Handshaker.cs b/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/Handshaker.cs index dd5dd4fb5..0f1d10105 100644 --- a/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/Handshaker.cs +++ b/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/Handshaker.cs @@ -1,16 +1,22 @@ using System; using System.IO; +using System.Threading; using System.Threading.Tasks; namespace WampSharp.RawSocket { internal class Handshaker { - public async Task GetHandshakeMessage(Stream stream) + public Task GetHandshakeMessage(Stream stream) + { + return GetHandshakeMessage(stream, CancellationToken.None); + } + + public async Task GetHandshakeMessage(Stream stream, CancellationToken cancellationToken) { byte[] bytes = new byte[4]; - await stream.ReadExactAsync(bytes, 0, bytes.Length) + await stream.ReadExactAsync(bytes, 0, bytes.Length, cancellationToken) .ConfigureAwait(false); ArraySegment arraySegment = new ArraySegment(bytes); @@ -18,13 +24,19 @@ await stream.ReadExactAsync(bytes, 0, bytes.Length) return new Handshake(arraySegment); } - public async Task SendHandshake(Stream stream, Handshake handshake) + public Task SendHandshake(Stream stream, Handshake handshake) + { + return SendHandshake(stream, handshake, CancellationToken.None); + } + + public async Task SendHandshake(Stream stream, Handshake handshake, CancellationToken cancellationToken) { byte[] handshakeResponse = handshake.ToArray(); await stream.WriteAsync(handshakeResponse, 0, - handshakeResponse.Length) + handshakeResponse.Length, + cancellationToken) .ConfigureAwait(false); } } diff --git a/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/NetworkStreamExtensions.cs b/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/NetworkStreamExtensions.cs index 2b067dcc9..3c9976d6a 100644 --- a/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/NetworkStreamExtensions.cs +++ b/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/NetworkStreamExtensions.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Threading; using System.Threading.Tasks; using Microsoft.IO; @@ -8,17 +9,27 @@ internal static class NetworkStreamExtensions { public static Task ReadExactAsync(this Stream networkStream, byte[] buffer, int position = 0) { - return networkStream.ReadExactAsync(buffer, position, buffer.Length); + return ReadExactAsync(networkStream, buffer, position, CancellationToken.None); } - public static async Task ReadExactAsync(this Stream networkStream, byte[] buffer, int position, int length) + public static Task ReadExactAsync(this Stream networkStream, byte[] buffer, int position, CancellationToken cancellationToken) + { + return networkStream.ReadExactAsync(buffer, position, buffer.Length, cancellationToken); + } + + public static Task ReadExactAsync(this Stream networkStream, byte[] buffer, int position, int length) + { + return ReadExactAsync(networkStream, buffer, position, length, CancellationToken.None); + } + + public static async Task ReadExactAsync(this Stream networkStream, byte[] buffer, int position, int length, CancellationToken cancellationToken) { int currentPosition = position; int readBytes = 0; while (readBytes != length) { - int currentlyRead = await networkStream.ReadAsync(buffer, currentPosition, length - readBytes).ConfigureAwait(false); + int currentlyRead = await networkStream.ReadAsync(buffer, currentPosition, length - readBytes, cancellationToken).ConfigureAwait(false); // If we read 0 bytes, we have reached the end of the stream. if (currentlyRead == 0) @@ -42,7 +53,5 @@ public static byte[] GetBufferWorkaround(this MemoryStream stream) return stream.GetBuffer(); } - - } } \ No newline at end of file diff --git a/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/RawSocketClientConnection.cs b/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/RawSocketClientConnection.cs index 45ff17a36..a33c62c01 100644 --- a/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/RawSocketClientConnection.cs +++ b/src/netstandard/Extensions/WampSharp.RawSocket/RawSocket/RawSocketClientConnection.cs @@ -2,6 +2,7 @@ using System.IO; using System.Net.Security; using System.Net.Sockets; +using System.Threading; using System.Threading.Tasks; using Microsoft.IO; using WampSharp.Core.Listener; @@ -83,17 +84,17 @@ private void OnConnectionClosed(object sender, EventArgs eventArgs) RaiseConnectionClosed(); } - public async void Connect() + public async void Connect(CancellationToken cancellationToken) { if (mConnection == null) { - await InnerConnect().ConfigureAwait(false); + await InnerConnect(cancellationToken).ConfigureAwait(false); } } - private async Task InnerConnect() + private async Task InnerConnect(CancellationToken cancellationToken) { - bool connected = await TryConnect().ConfigureAwait(false); + bool connected = await TryConnect(cancellationToken).ConfigureAwait(false); if (connected) { @@ -101,7 +102,7 @@ private async Task InnerConnect() } } - private async Task TryConnect() + private async Task TryConnect(CancellationToken cancellationToken) { try { @@ -119,9 +120,9 @@ private async Task TryConnect() Handshake handshakeRequest = GetHandshakeRequest(); - await mHandshaker.SendHandshake(stream, handshakeRequest).ConfigureAwait(false); + await mHandshaker.SendHandshake(stream, handshakeRequest, cancellationToken).ConfigureAwait(false); - Handshake handshakeResponse = await mHandshaker.GetHandshakeMessage(stream).ConfigureAwait(false); + Handshake handshakeResponse = await mHandshaker.GetHandshakeMessage(stream, cancellationToken).ConfigureAwait(false); if (handshakeResponse.IsError) { diff --git a/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/ControlledBinaryWebSocketConnection.cs b/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/ControlledBinaryWebSocketConnection.cs index da291c997..c6ed978bc 100644 --- a/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/ControlledBinaryWebSocketConnection.cs +++ b/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/ControlledBinaryWebSocketConnection.cs @@ -1,5 +1,6 @@ using System; using System.Net.WebSockets; +using System.Threading; using WampSharp.Core.Listener; using WampSharp.V2.Binding; @@ -17,9 +18,9 @@ public ControlledBinaryWebSocketConnection(ClientWebSocket clientWebSocket, Uri { } - public void Connect() + public void Connect(CancellationToken cancellationToken) { - base.InnerConnect(); + base.InnerConnect(cancellationToken); } } } \ No newline at end of file diff --git a/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/ControlledTextWebSocketConnection.cs b/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/ControlledTextWebSocketConnection.cs index 0ac0834bf..61d18f482 100644 --- a/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/ControlledTextWebSocketConnection.cs +++ b/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/ControlledTextWebSocketConnection.cs @@ -1,5 +1,6 @@ using System; using System.Net.WebSockets; +using System.Threading; using WampSharp.Core.Listener; using WampSharp.V2.Binding; @@ -15,9 +16,9 @@ public ControlledTextWebSocketConnection(ClientWebSocket clientWebSocket, Uri ad { } - public void Connect() + public void Connect(CancellationToken cancellationToken) { - base.InnerConnect(); + base.InnerConnect(cancellationToken); } } } \ No newline at end of file diff --git a/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/WebSocketWrapperConnection.cs b/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/WebSocketWrapperConnection.cs index e6bc3e8ef..18d7b10ff 100644 --- a/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/WebSocketWrapperConnection.cs +++ b/src/netstandard/Extensions/WampSharp.WebSockets/WebSockets/WebSocketWrapperConnection.cs @@ -52,9 +52,9 @@ private ArraySegment GetMessageInBytes(WampMessage message) protected abstract WebSocketMessageType WebSocketMessageType { get; } - protected async void InnerConnect() + protected async void InnerConnect(CancellationToken cancellationToken) { - bool connected = await TryConnect(); + bool connected = await TryConnect(cancellationToken); if (connected) { @@ -62,11 +62,11 @@ protected async void InnerConnect() } } - private async Task TryConnect() + private async Task TryConnect(CancellationToken cancellationToken) { try { - await this.ClientWebSocket.ConnectAsync(mAddressUri, mCancellationToken) + await this.ClientWebSocket.ConnectAsync(mAddressUri, cancellationToken) .ConfigureAwait(false); RaiseConnectionOpen(); diff --git a/src/netstandard/Tests/WampSharp.Tests.TestHelpers/Integration/MockConnectionListener.cs b/src/netstandard/Tests/WampSharp.Tests.TestHelpers/Integration/MockConnectionListener.cs index 92e2862b6..95c58b9ca 100644 --- a/src/netstandard/Tests/WampSharp.Tests.TestHelpers/Integration/MockConnectionListener.cs +++ b/src/netstandard/Tests/WampSharp.Tests.TestHelpers/Integration/MockConnectionListener.cs @@ -1,5 +1,6 @@ using System; using System.Reactive.Subjects; +using System.Threading; using WampSharp.Core.Listener; using WampSharp.Core.Message; using WampSharp.Core.Serialization; @@ -34,7 +35,7 @@ private void OnNewConnection(IWampConnection connection) // Yuck IControlledWampConnection casted = connection as IControlledWampConnection; - casted.Connect(); + casted.Connect(CancellationToken.None); } private class ListenerControlledConnection : IControlledWampConnection @@ -48,11 +49,11 @@ public ListenerControlledConnection(MockConnectionListener listener, I mListener = listener; } - public void Connect() + public void Connect(CancellationToken cancellationToken) { mListener.OnNewConnection(mConnection.SideBToSideA); - mConnection.SideAToSideB.Connect(); + mConnection.SideAToSideB.Connect(cancellationToken); } public void Dispose() diff --git a/src/netstandard/Tests/WampSharp.Tests.TestHelpers/MockConnection.cs b/src/netstandard/Tests/WampSharp.Tests.TestHelpers/MockConnection.cs index 10c86c45d..e9a5fc786 100644 --- a/src/netstandard/Tests/WampSharp.Tests.TestHelpers/MockConnection.cs +++ b/src/netstandard/Tests/WampSharp.Tests.TestHelpers/MockConnection.cs @@ -1,5 +1,6 @@ using System; using System.Reactive.Subjects; +using System.Threading; using WampSharp.Core.Listener; using WampSharp.Core.Message; using WampSharp.Core.Serialization; @@ -58,7 +59,7 @@ private void OnNewMessage(WampMessage wampMessage) this.MessageArrived?.Invoke(this, new WampMessageArrivedEventArgs(wampMessage)); } - public void Connect() + public void Connect(CancellationToken cancellationToken) { this.RaiseConnectionOpen(); } diff --git a/src/netstandard/Tests/WampSharp.Tests.Wampv2/TestHelpers/Integration/WampPlayground.cs b/src/netstandard/Tests/WampSharp.Tests.Wampv2/TestHelpers/Integration/WampPlayground.cs index 034b37048..0f5d564c9 100644 --- a/src/netstandard/Tests/WampSharp.Tests.Wampv2/TestHelpers/Integration/WampPlayground.cs +++ b/src/netstandard/Tests/WampSharp.Tests.Wampv2/TestHelpers/Integration/WampPlayground.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading; using Newtonsoft.Json.Linq; using WampSharp.Binding; using WampSharp.Core.Client; @@ -87,7 +88,7 @@ public IWampChannel CreateNewChannel(string realm, public IWampServerProxy CreateRawConnection(IWampClient client) { IControlledWampConnection connection = CreateClientConnection(); - connection.Connect(); + connection.Connect(CancellationToken.None); return mProxyFactory.Create(client, connection); } diff --git a/src/netstandard/Tests/WampSharp.Tests.Wampv2/TestHelpers/Integration/WampPlaygroundRoleExtensions.cs b/src/netstandard/Tests/WampSharp.Tests.Wampv2/TestHelpers/Integration/WampPlaygroundRoleExtensions.cs index 7d8677d18..3b1324b83 100644 --- a/src/netstandard/Tests/WampSharp.Tests.Wampv2/TestHelpers/Integration/WampPlaygroundRoleExtensions.cs +++ b/src/netstandard/Tests/WampSharp.Tests.Wampv2/TestHelpers/Integration/WampPlaygroundRoleExtensions.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using WampSharp.Tests.Wampv2.Integration; +using WampSharp.V2; using WampSharp.V2.Realm; namespace WampSharp.Tests.Wampv2.TestHelpers.Integration diff --git a/src/netstandard/Tests/WampSharp.Tests/MockListener.cs b/src/netstandard/Tests/WampSharp.Tests/MockListener.cs index eeccb963f..cfd07f249 100644 --- a/src/netstandard/Tests/WampSharp.Tests/MockListener.cs +++ b/src/netstandard/Tests/WampSharp.Tests/MockListener.cs @@ -1,5 +1,6 @@ using System; using System.Reactive.Subjects; +using System.Threading; using WampSharp.Core.Listener; namespace WampSharp.Tests @@ -21,7 +22,7 @@ public void OnNext(IWampConnection value) if (value is IControlledWampConnection casted) { - casted.Connect(); + casted.Connect(CancellationToken.None); } } diff --git a/src/netstandard/WampSharp.WAMP1/WAMP1/V1/Api/Client/IWampChannel.cs b/src/netstandard/WampSharp.WAMP1/WAMP1/V1/Api/Client/IWampChannel.cs index 4ac9f5d53..f5f1a9fce 100644 --- a/src/netstandard/WampSharp.WAMP1/WAMP1/V1/Api/Client/IWampChannel.cs +++ b/src/netstandard/WampSharp.WAMP1/WAMP1/V1/Api/Client/IWampChannel.cs @@ -1,10 +1,19 @@ using System.Reactive.Subjects; +using System.Threading; using System.Threading.Tasks; using WampSharp.V1.Auxiliary.Client; using WampSharp.V1.Core.Contracts; namespace WampSharp.V1 { + public static class WampChannelExtensions + { + public static Task OpenAsync(this IWampChannel channel) + { + return channel.OpenAsync(CancellationToken.None); + } + } + public interface IWampChannel { IWampServer GetServerProxy(IWampClient callbackClient); @@ -24,7 +33,7 @@ public interface IWampChannel void Open(); - Task OpenAsync(); + Task OpenAsync(CancellationToken cancellationToken); void Close(); } diff --git a/src/netstandard/WampSharp.WAMP1/WAMP1/V1/Api/Client/WampChannel.cs b/src/netstandard/WampSharp.WAMP1/WAMP1/V1/Api/Client/WampChannel.cs index 80f8bc531..dfcc75a1c 100644 --- a/src/netstandard/WampSharp.WAMP1/WAMP1/V1/Api/Client/WampChannel.cs +++ b/src/netstandard/WampSharp.WAMP1/WAMP1/V1/Api/Client/WampChannel.cs @@ -3,6 +3,7 @@ using System.Reactive.Linq; using System.Reactive.Subjects; using System.Reactive.Threading.Tasks; +using System.Threading; using System.Threading.Tasks; using WampSharp.Core.Listener; using WampSharp.V1.Auxiliary.Client; @@ -66,7 +67,7 @@ public IWampClientConnectionMonitor GetMonitor() public void Open() { - Task task = OpenAsync(); + Task task = OpenAsync(CancellationToken.None); try { @@ -78,7 +79,7 @@ public void Open() } } - public Task OpenAsync() + public Task OpenAsync(CancellationToken cancellationToken) { var connectedObservable = Observable.FromEventPattern @@ -109,7 +110,7 @@ public Task OpenAsync() Task task = firstConnectionOrError.ToTask(); - mConnection.Connect(); + mConnection.Connect(cancellationToken); return task; } diff --git a/src/netstandard/WampSharp/Core/Listener/Connections/IControlledWampConnection.cs b/src/netstandard/WampSharp/Core/Listener/Connections/IControlledWampConnection.cs index 893a94096..e5a7cc647 100644 --- a/src/netstandard/WampSharp/Core/Listener/Connections/IControlledWampConnection.cs +++ b/src/netstandard/WampSharp/Core/Listener/Connections/IControlledWampConnection.cs @@ -1,3 +1,5 @@ +using System.Threading; + namespace WampSharp.Core.Listener { /// @@ -15,6 +17,7 @@ public interface IControlledWampConnection : /// /// Tries to establish a connection to the remote server. /// - void Connect(); + /// + void Connect(CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/src/netstandard/WampSharp/Core/Listener/Connections/ReviveClientConnection.cs b/src/netstandard/WampSharp/Core/Listener/Connections/ReviveClientConnection.cs index ed1aaf848..eb5b5f1f1 100644 --- a/src/netstandard/WampSharp/Core/Listener/Connections/ReviveClientConnection.cs +++ b/src/netstandard/WampSharp/Core/Listener/Connections/ReviveClientConnection.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using WampSharp.Core.Message; namespace WampSharp.Core.Listener @@ -13,14 +14,14 @@ public ReviveClientConnection(Func> factory) mFactory = factory; } - public void Connect() + public void Connect(CancellationToken cancellationToken) { if (mConnection == null) { mConnection = SetupConnection(); } - mConnection.Connect(); + mConnection.Connect(cancellationToken); } private IControlledWampConnection SetupConnection() diff --git a/src/netstandard/WampSharp/WAMP2/V2/Api/Client/IWampChannel.cs b/src/netstandard/WampSharp/WAMP2/V2/Api/Client/IWampChannel.cs index 704c4afe8..5c7476bff 100644 --- a/src/netstandard/WampSharp/WAMP2/V2/Api/Client/IWampChannel.cs +++ b/src/netstandard/WampSharp/WAMP2/V2/Api/Client/IWampChannel.cs @@ -1,9 +1,18 @@ -using System.Threading.Tasks; +using System.Threading; +using System.Threading.Tasks; using WampSharp.V2.Client; using WampSharp.V2.Core.Contracts; namespace WampSharp.V2 { + public static class WampChannelExtensions + { + public static Task Open(this IWampChannel channel) + { + return channel.Open(CancellationToken.None); + } + } + /// /// Represents a WAMP client session. /// @@ -19,7 +28,7 @@ public interface IWampChannel /// /// A task that is complete when the connection is /// established. - Task Open(); + Task Open(CancellationToken cancellationToken); /// /// Closes the session violently. diff --git a/src/netstandard/WampSharp/WAMP2/V2/Api/Server/ServiceRealm/ServiceHostedRealmContainer.cs b/src/netstandard/WampSharp/WAMP2/V2/Api/Server/ServiceRealm/ServiceHostedRealmContainer.cs index b9f54a844..494a5251e 100644 --- a/src/netstandard/WampSharp/WAMP2/V2/Api/Server/ServiceRealm/ServiceHostedRealmContainer.cs +++ b/src/netstandard/WampSharp/WAMP2/V2/Api/Server/ServiceRealm/ServiceHostedRealmContainer.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Concurrent; using System.Reactive.Concurrency; +using System.Threading; using WampSharp.V2.Realm; namespace WampSharp.V2 @@ -32,7 +33,7 @@ private IWampHostedRealm BuildRealm(string name) channel.RealmProxy.Monitor.ConnectionEstablished += connectionEstablished; - channel.Open(); + channel.Open(CancellationToken.None); channel.RealmProxy.Monitor.ConnectionEstablished -= connectionEstablished; diff --git a/src/netstandard/WampSharp/WAMP2/V2/Client/WampChannel.cs b/src/netstandard/WampSharp/WAMP2/V2/Client/WampChannel.cs index bc08f142e..96aaaadf5 100644 --- a/src/netstandard/WampSharp/WAMP2/V2/Client/WampChannel.cs +++ b/src/netstandard/WampSharp/WAMP2/V2/Client/WampChannel.cs @@ -44,7 +44,7 @@ private void OnConnectionError(object sender, WampConnectionErrorEventArgs e) public IWampRealmProxy RealmProxy => mClient.Realm; - public Task Open() + public Task Open(CancellationToken cancellationToken) { if (Interlocked.CompareExchange(ref mConnectCalled, 1, 0) != 0) { @@ -54,7 +54,7 @@ public Task Open() else { Task openTask = mClient.OpenTask; - mConnection.Connect(); + mConnection.Connect(cancellationToken); return openTask; } } diff --git a/src/netstandard/WampSharp/WAMP2/V2/Fluent/ScheduledWampConnection.cs b/src/netstandard/WampSharp/WAMP2/V2/Fluent/ScheduledWampConnection.cs index 8ba01fb7b..87b85148c 100644 --- a/src/netstandard/WampSharp/WAMP2/V2/Fluent/ScheduledWampConnection.cs +++ b/src/netstandard/WampSharp/WAMP2/V2/Fluent/ScheduledWampConnection.cs @@ -2,6 +2,7 @@ using System.Reactive; using System.Reactive.Concurrency; using System.Reactive.Linq; +using System.Threading; using WampSharp.Core.Listener; using WampSharp.Core.Message; @@ -65,9 +66,9 @@ private IEventPatternSource GetEventHandler(Action addH .ToEventPattern(); } - public void Connect() + public void Connect(CancellationToken cancellationToken) { - mConnection.Connect(); + mConnection.Connect(cancellationToken); } public void Dispose() diff --git a/src/netstandard/WampSharp/WAMP2/V2/Transports/InMemory/InMemoryConnectionListener.cs b/src/netstandard/WampSharp/WAMP2/V2/Transports/InMemory/InMemoryConnectionListener.cs index a200d14cf..00613df27 100644 --- a/src/netstandard/WampSharp/WAMP2/V2/Transports/InMemory/InMemoryConnectionListener.cs +++ b/src/netstandard/WampSharp/WAMP2/V2/Transports/InMemory/InMemoryConnectionListener.cs @@ -4,6 +4,7 @@ using System.Reactive.Disposables; using System.Reactive.Linq; using System.Reactive.Subjects; +using System.Threading; using WampSharp.Core.Listener; using WampSharp.Core.Message; using WampSharp.V2.Binding; @@ -109,7 +110,7 @@ private void OnNewMessage(WampMessage wampMessage) this.MessageArrived?.Invoke(this, new WampMessageArrivedEventArgs(wampMessage)); } - public void Connect() + public void Connect(CancellationToken cancellationToken) { mConnectionOpen.OnNext(Unit.Default); } From 268ff655c95ceea6523385d08566766c776a79ea Mon Sep 17 00:00:00 2001 From: Elad Zelingher Date: Sat, 19 Dec 2020 00:36:46 -0500 Subject: [PATCH 2/7] Updating to net5.0 --- .../WampSharp.CraClientSample/WampSharp.CraClientSample.csproj | 2 +- .../WampSharp.CraServerSample/WampSharp.CraServerSample.csproj | 2 +- .../WampSharp.PubSubServerSample.csproj | 2 +- .../WampSharp.RpcClientSample/WampSharp.RpcClientSample.csproj | 2 +- .../WampSharp.RpcServerSample/WampSharp.RpcServerSample.csproj | 2 +- .../WampSharp.Samples.AspNetCore.Router.csproj | 2 +- .../WampSharp.Samples.Authentication.csproj | 2 +- .../WampSharp.Samples.Callee/WampSharp.Samples.Callee.csproj | 2 +- .../WampSharp.Samples.Caller/WampSharp.Samples.Caller.csproj | 2 +- .../WampSharp.Samples.Common/WampSharp.Samples.Common.csproj | 2 +- .../WampSharp.Samples.Publisher.csproj | 2 +- .../WampSharp.Samples.Subscriber.csproj | 2 +- .../WampSharp.Samples.WampCra.Client.csproj | 2 +- .../WampSharp.Samples.WampCra.Router.csproj | 2 +- .../Tests/WampSharp.Tests.Wampv2/WampSharp.Tests.Wampv2.csproj | 2 +- src/netstandard/Tests/WampSharp.Tests/WampSharp.Tests.csproj | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/netstandard/Samples/WAMP1/WampSharp.CraClientSample/WampSharp.CraClientSample.csproj b/src/netstandard/Samples/WAMP1/WampSharp.CraClientSample/WampSharp.CraClientSample.csproj index 07dc32049..b31e5fb8e 100644 --- a/src/netstandard/Samples/WAMP1/WampSharp.CraClientSample/WampSharp.CraClientSample.csproj +++ b/src/netstandard/Samples/WAMP1/WampSharp.CraClientSample/WampSharp.CraClientSample.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + net5.0 diff --git a/src/netstandard/Samples/WAMP1/WampSharp.CraServerSample/WampSharp.CraServerSample.csproj b/src/netstandard/Samples/WAMP1/WampSharp.CraServerSample/WampSharp.CraServerSample.csproj index 07dc32049..b31e5fb8e 100644 --- a/src/netstandard/Samples/WAMP1/WampSharp.CraServerSample/WampSharp.CraServerSample.csproj +++ b/src/netstandard/Samples/WAMP1/WampSharp.CraServerSample/WampSharp.CraServerSample.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + net5.0 diff --git a/src/netstandard/Samples/WAMP1/WampSharp.PubSubServerSample/WampSharp.PubSubServerSample.csproj b/src/netstandard/Samples/WAMP1/WampSharp.PubSubServerSample/WampSharp.PubSubServerSample.csproj index 07dc32049..b31e5fb8e 100644 --- a/src/netstandard/Samples/WAMP1/WampSharp.PubSubServerSample/WampSharp.PubSubServerSample.csproj +++ b/src/netstandard/Samples/WAMP1/WampSharp.PubSubServerSample/WampSharp.PubSubServerSample.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + net5.0 diff --git a/src/netstandard/Samples/WAMP1/WampSharp.RpcClientSample/WampSharp.RpcClientSample.csproj b/src/netstandard/Samples/WAMP1/WampSharp.RpcClientSample/WampSharp.RpcClientSample.csproj index 07dc32049..b31e5fb8e 100644 --- a/src/netstandard/Samples/WAMP1/WampSharp.RpcClientSample/WampSharp.RpcClientSample.csproj +++ b/src/netstandard/Samples/WAMP1/WampSharp.RpcClientSample/WampSharp.RpcClientSample.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + net5.0 diff --git a/src/netstandard/Samples/WAMP1/WampSharp.RpcServerSample/WampSharp.RpcServerSample.csproj b/src/netstandard/Samples/WAMP1/WampSharp.RpcServerSample/WampSharp.RpcServerSample.csproj index 07dc32049..b31e5fb8e 100644 --- a/src/netstandard/Samples/WAMP1/WampSharp.RpcServerSample/WampSharp.RpcServerSample.csproj +++ b/src/netstandard/Samples/WAMP1/WampSharp.RpcServerSample/WampSharp.RpcServerSample.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + net5.0 diff --git a/src/netstandard/Samples/WAMP2/WampSharp.Samples.AspNetCore.Router/WampSharp.Samples.AspNetCore.Router.csproj b/src/netstandard/Samples/WAMP2/WampSharp.Samples.AspNetCore.Router/WampSharp.Samples.AspNetCore.Router.csproj index 25eacfc4a..a6c8f268a 100644 --- a/src/netstandard/Samples/WAMP2/WampSharp.Samples.AspNetCore.Router/WampSharp.Samples.AspNetCore.Router.csproj +++ b/src/netstandard/Samples/WAMP2/WampSharp.Samples.AspNetCore.Router/WampSharp.Samples.AspNetCore.Router.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + net5.0 diff --git a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Authentication/WampSharp.Samples.Authentication.csproj b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Authentication/WampSharp.Samples.Authentication.csproj index f9362f569..5ac07819b 100644 --- a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Authentication/WampSharp.Samples.Authentication.csproj +++ b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Authentication/WampSharp.Samples.Authentication.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp3.0 + net461;net5.0 Exe diff --git a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Callee/WampSharp.Samples.Callee.csproj b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Callee/WampSharp.Samples.Callee.csproj index 30ee39bed..09f022c8f 100644 --- a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Callee/WampSharp.Samples.Callee.csproj +++ b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Callee/WampSharp.Samples.Callee.csproj @@ -2,7 +2,7 @@ Exe - net461;netcoreapp3.0 + net461;net5.0 8 diff --git a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Caller/WampSharp.Samples.Caller.csproj b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Caller/WampSharp.Samples.Caller.csproj index 4d2d14d1c..bb93786ad 100644 --- a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Caller/WampSharp.Samples.Caller.csproj +++ b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Caller/WampSharp.Samples.Caller.csproj @@ -2,7 +2,7 @@ Exe - net461;netcoreapp3.0 + net461;net5.0 diff --git a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Common/WampSharp.Samples.Common.csproj b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Common/WampSharp.Samples.Common.csproj index d5207beda..419a23cdc 100644 --- a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Common/WampSharp.Samples.Common.csproj +++ b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Common/WampSharp.Samples.Common.csproj @@ -1,7 +1,7 @@  - net461;netcoreapp3.0 + net461;net5.0 8 diff --git a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Publisher/WampSharp.Samples.Publisher.csproj b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Publisher/WampSharp.Samples.Publisher.csproj index 4d2d14d1c..bb93786ad 100644 --- a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Publisher/WampSharp.Samples.Publisher.csproj +++ b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Publisher/WampSharp.Samples.Publisher.csproj @@ -2,7 +2,7 @@ Exe - net461;netcoreapp3.0 + net461;net5.0 diff --git a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Subscriber/WampSharp.Samples.Subscriber.csproj b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Subscriber/WampSharp.Samples.Subscriber.csproj index dc1d8d10f..1d37ec835 100644 --- a/src/netstandard/Samples/WAMP2/WampSharp.Samples.Subscriber/WampSharp.Samples.Subscriber.csproj +++ b/src/netstandard/Samples/WAMP2/WampSharp.Samples.Subscriber/WampSharp.Samples.Subscriber.csproj @@ -2,7 +2,7 @@ Exe - net461;netcoreapp3.0 + net461;net5.0 8 diff --git a/src/netstandard/Samples/WAMP2/WampSharp.Samples.WampCra.Client/WampSharp.Samples.WampCra.Client.csproj b/src/netstandard/Samples/WAMP2/WampSharp.Samples.WampCra.Client/WampSharp.Samples.WampCra.Client.csproj index 468003c18..b9074785a 100644 --- a/src/netstandard/Samples/WAMP2/WampSharp.Samples.WampCra.Client/WampSharp.Samples.WampCra.Client.csproj +++ b/src/netstandard/Samples/WAMP2/WampSharp.Samples.WampCra.Client/WampSharp.Samples.WampCra.Client.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp3.0 + net461;net5.0 Exe diff --git a/src/netstandard/Samples/WAMP2/WampSharp.Samples.WampCra.Router/WampSharp.Samples.WampCra.Router.csproj b/src/netstandard/Samples/WAMP2/WampSharp.Samples.WampCra.Router/WampSharp.Samples.WampCra.Router.csproj index 542293d5d..11949661d 100644 --- a/src/netstandard/Samples/WAMP2/WampSharp.Samples.WampCra.Router/WampSharp.Samples.WampCra.Router.csproj +++ b/src/netstandard/Samples/WAMP2/WampSharp.Samples.WampCra.Router/WampSharp.Samples.WampCra.Router.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp3.0 + net461;net5.0 Exe diff --git a/src/netstandard/Tests/WampSharp.Tests.Wampv2/WampSharp.Tests.Wampv2.csproj b/src/netstandard/Tests/WampSharp.Tests.Wampv2/WampSharp.Tests.Wampv2.csproj index f26ad237f..8fcace4a0 100644 --- a/src/netstandard/Tests/WampSharp.Tests.Wampv2/WampSharp.Tests.Wampv2.csproj +++ b/src/netstandard/Tests/WampSharp.Tests.Wampv2/WampSharp.Tests.Wampv2.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp3.0 + net461;net5.0 diff --git a/src/netstandard/Tests/WampSharp.Tests/WampSharp.Tests.csproj b/src/netstandard/Tests/WampSharp.Tests/WampSharp.Tests.csproj index 8439b496d..dd26ae47d 100644 --- a/src/netstandard/Tests/WampSharp.Tests/WampSharp.Tests.csproj +++ b/src/netstandard/Tests/WampSharp.Tests/WampSharp.Tests.csproj @@ -1,6 +1,6 @@  - net461;netcoreapp3.0 + net461;net5.0 NETCORE VALUETUPLE From 686a9c82abb30994490719b6f7854fe67969afda Mon Sep 17 00:00:00 2001 From: Elad Zelingher Date: Sat, 19 Dec 2020 00:41:16 -0500 Subject: [PATCH 3/7] Modifying build --- .github/workflows/githubPackages.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/githubPackages.yml b/.github/workflows/githubPackages.yml index fbdeb0453..4dbb5ef52 100644 --- a/.github/workflows/githubPackages.yml +++ b/.github/workflows/githubPackages.yml @@ -1,9 +1,9 @@ -name: GitHub packages NuGet generation +name: GitHub packages Blazor NuGet generation on: push: branches: - - master + - open-cancellationToken jobs: build: @@ -16,7 +16,7 @@ jobs: - name: Build solution and generate NuGet package run: | cd src\netstandard\ - dotnet pack -c Release -o out /p:Version="${{ secrets.PACKAGE_VERSION }}-develop-${{ github.run_number }}" + dotnet pack -c Release -o out /p:Version="${{ secrets.PACKAGE_VERSION }}-open-cancellationToken-${{ github.run_number }}" - name: Install NuGet client uses: warrenbuckley/Setup-Nuget@v1 @@ -27,4 +27,4 @@ jobs: - name: Push generated package to GitHub registry run: | cd src\netstandard\ - nuget push .\out\*.nupkg -Source "GPR" -SkipDuplicate + nuget push .\out\*.nupkg -Source "GPR" -SkipDuplicate \ No newline at end of file From 896a879940ed62f19ddde2691c7b122ff412c576 Mon Sep 17 00:00:00 2001 From: Elad Zelingher Date: Sat, 19 Dec 2020 00:47:56 -0500 Subject: [PATCH 4/7] Updating setup nuget --- .github/workflows/githubPackages.yml | 4 ++-- .github/workflows/nugetGallery.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/githubPackages.yml b/.github/workflows/githubPackages.yml index 4dbb5ef52..7beee130e 100644 --- a/.github/workflows/githubPackages.yml +++ b/.github/workflows/githubPackages.yml @@ -1,4 +1,4 @@ -name: GitHub packages Blazor NuGet generation +name: GitHub packages NuGet generation on: push: @@ -19,7 +19,7 @@ jobs: dotnet pack -c Release -o out /p:Version="${{ secrets.PACKAGE_VERSION }}-open-cancellationToken-${{ github.run_number }}" - name: Install NuGet client - uses: warrenbuckley/Setup-Nuget@v1 + uses: nuget/setup-nuget@v1 - name: Add private GitHub registry to NuGet run: nuget sources add -name "GPR" -Source https://nuget.pkg.github.com/Code-Sharp/index.json -Username Code-Sharp -Password ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/nugetGallery.yml b/.github/workflows/nugetGallery.yml index 80d8c584c..c2c95b0ec 100644 --- a/.github/workflows/nugetGallery.yml +++ b/.github/workflows/nugetGallery.yml @@ -20,7 +20,7 @@ jobs: dotnet pack -c Release -o out - name: Install NuGet client - uses: warrenbuckley/Setup-Nuget@v1 + uses: nuget/setup-nuget@v1 - name: Push generated package to NuGet gallery run: | From b27db08addd8062fae13d463e51a9b1e043a4bf9 Mon Sep 17 00:00:00 2001 From: Elad Zelingher Date: Sat, 19 Dec 2020 00:53:44 -0500 Subject: [PATCH 5/7] Updating dotnet to 5.0 --- .github/workflows/dotnetcore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 889f4e4fb..d6b7f501d 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.0.101 + dotnet-version: 5.0 - name: Build with dotnet working-directory: src/netstandard/ run: dotnet build --configuration Release From e85c464d8669b0832b40cd3e14b0afdf7c5716fd Mon Sep 17 00:00:00 2001 From: Elad Zelingher Date: Sat, 19 Dec 2020 01:13:05 -0500 Subject: [PATCH 6/7] Try using 5.0.1 --- .github/workflows/dotnetcore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index d6b7f501d..dead4a8eb 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0 + dotnet-version: 5.0.1 - name: Build with dotnet working-directory: src/netstandard/ run: dotnet build --configuration Release From 9ad0f993de86e92ee619750ce07962ed7be3ced3 Mon Sep 17 00:00:00 2001 From: Elad Zelingher Date: Sat, 19 Dec 2020 01:24:59 -0500 Subject: [PATCH 7/7] Update dotnetcore.yml --- .github/workflows/dotnetcore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index dead4a8eb..fff8d31e4 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,7 +12,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.1 + dotnet-version: 5.0.101 - name: Build with dotnet working-directory: src/netstandard/ run: dotnet build --configuration Release