diff --git a/src/Console.Sample/Program.cs b/src/Console.Sample/Program.cs index a28ba10..7bfb2f2 100644 --- a/src/Console.Sample/Program.cs +++ b/src/Console.Sample/Program.cs @@ -18,7 +18,7 @@ internal class Program private static OpenClient _client; - private static readonly List _disposables = new List(); + private static readonly List _disposables = new(); private static async Task Main() { @@ -298,6 +298,13 @@ private static void ProcessSubscriptionCommand(string[] commandSplit) private static async void RefreshToken() { + if (string.IsNullOrWhiteSpace(_token.RefreshToken)) + { + Console.Write("Refresh Token: "); + + _token.RefreshToken = Console.ReadLine(); + } + Console.WriteLine("Sending ProtoOARefreshTokenReq..."); var request = new ProtoOARefreshTokenReq diff --git a/src/OpenAPI.Net/OpenAPI.Net.csproj b/src/OpenAPI.Net/OpenAPI.Net.csproj index c580b18..7b73bde 100644 --- a/src/OpenAPI.Net/OpenAPI.Net.csproj +++ b/src/OpenAPI.Net/OpenAPI.Net.csproj @@ -9,7 +9,7 @@ cTrader, Open API, Spotware A .NET RX library for Spotware Open API Spotware.OpenAPI.Net - 1.3.9-rc0 + 1.3.9 AnyCPU Spotware Spotware diff --git a/src/OpenAPI.Net/OpenClient.cs b/src/OpenAPI.Net/OpenClient.cs index 4b821cb..fc0d3ef 100644 --- a/src/OpenAPI.Net/OpenClient.cs +++ b/src/OpenAPI.Net/OpenClient.cs @@ -169,8 +169,7 @@ public IDisposable Subscribe(IObserver observer) /// The client message ID (optional) /// If getting message payload type fails /// Task - public async Task SendMessage(T message, string clientMsgId = null) where T : - IMessage + public async Task SendMessage(T message, string clientMsgId = null) where T : IMessage { var protoMessage = MessageFactory.GetMessage(message.GetPayloadType(), message.ToByteString(), clientMsgId); @@ -185,8 +184,7 @@ public async Task SendMessage(T message, string clientMsgId = null) where T : /// Message Payload Type (ProtoPayloadType) /// The client message ID (optional) /// Task - public async Task SendMessage(T message, ProtoPayloadType payloadType, string clientMsgId = null) where T : - IMessage + public async Task SendMessage(T message, ProtoPayloadType payloadType, string clientMsgId = null) where T : IMessage { var protoMessage = MessageFactory.GetMessage(message, payloadType, clientMsgId); @@ -201,8 +199,7 @@ public async Task SendMessage(T message, ProtoPayloadType payloadType, string /// Message Payload Type (ProtoOAPayloadType) /// The client message ID (optional) /// Task - public async Task SendMessage(T message, ProtoOAPayloadType payloadType, string clientMsgId = null) where T : - IMessage + public async Task SendMessage(T message, ProtoOAPayloadType payloadType, string clientMsgId = null) where T : IMessage { var protoMessage = MessageFactory.GetMessage(message, payloadType, clientMsgId); @@ -457,7 +454,14 @@ private async void SendHeartbeat() { if (IsDisposed || DateTimeOffset.Now - LastSentMessageTime < _heartbeatInerval) return; - await SendMessage(_heartbeatEvent, ProtoPayloadType.HeartbeatEvent).ConfigureAwait(false); + try + { + await SendMessage(_heartbeatEvent, ProtoPayloadType.HeartbeatEvent).ConfigureAwait(false); + } + catch (Exception ex) + { + OnError(ex); + } } ///