Skip to content

Commit

Permalink
Merge pull request #5 from spotware/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
amusleh-spotware-com authored Mar 12, 2022
2 parents 8bf506a + f10a484 commit b2ecab7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/Console.Sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class Program

private static OpenClient _client;

private static readonly List<IDisposable> _disposables = new List<IDisposable>();
private static readonly List<IDisposable> _disposables = new();

private static async Task Main()
{
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/OpenAPI.Net/OpenAPI.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageTags>cTrader, Open API, Spotware</PackageTags>
<Description>A .NET RX library for Spotware Open API</Description>
<PackageId>Spotware.OpenAPI.Net</PackageId>
<Version>1.3.9-rc0</Version>
<Version>1.3.9</Version>
<Platforms>AnyCPU</Platforms>
<Company>Spotware</Company>
<Authors>Spotware</Authors>
Expand Down
18 changes: 11 additions & 7 deletions src/OpenAPI.Net/OpenClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ public IDisposable Subscribe(IObserver<IMessage> observer)
/// <param name="clientMsgId">The client message ID (optional)</param>
/// <exception cref="InvalidOperationException">If getting message payload type fails</exception>
/// <returns>Task</returns>
public async Task SendMessage<T>(T message, string clientMsgId = null) where T :
IMessage
public async Task SendMessage<T>(T message, string clientMsgId = null) where T : IMessage
{
var protoMessage = MessageFactory.GetMessage(message.GetPayloadType(), message.ToByteString(), clientMsgId);

Expand All @@ -185,8 +184,7 @@ public async Task SendMessage<T>(T message, string clientMsgId = null) where T :
/// <param name="payloadType">Message Payload Type (ProtoPayloadType)</param>
/// <param name="clientMsgId">The client message ID (optional)</param>
/// <returns>Task</returns>
public async Task SendMessage<T>(T message, ProtoPayloadType payloadType, string clientMsgId = null) where T :
IMessage
public async Task SendMessage<T>(T message, ProtoPayloadType payloadType, string clientMsgId = null) where T : IMessage
{
var protoMessage = MessageFactory.GetMessage(message, payloadType, clientMsgId);

Expand All @@ -201,8 +199,7 @@ public async Task SendMessage<T>(T message, ProtoPayloadType payloadType, string
/// <param name="payloadType">Message Payload Type (ProtoOAPayloadType)</param>
/// <param name="clientMsgId">The client message ID (optional)</param>
/// <returns>Task</returns>
public async Task SendMessage<T>(T message, ProtoOAPayloadType payloadType, string clientMsgId = null) where T :
IMessage
public async Task SendMessage<T>(T message, ProtoOAPayloadType payloadType, string clientMsgId = null) where T : IMessage
{
var protoMessage = MessageFactory.GetMessage(message, payloadType, clientMsgId);

Expand Down Expand Up @@ -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);
}
}

/// <summary>
Expand Down

0 comments on commit b2ecab7

Please sign in to comment.