Skip to content

Commit

Permalink
PingTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Apr 13, 2022
1 parent 6ca273a commit c3cb8ee
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 138 deletions.
32 changes: 3 additions & 29 deletions sandbox/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,46 +39,20 @@ public static async Task Main()
//LoggerFactory = new MinimumConsoleLoggerFactory(LogLevel.Information),
Serializer = new MessagePackNatsSerializer(),
ConnectTimeout = TimeSpan.FromSeconds(1),
ConnectOptions = ConnectOptions.Default with { Echo = true, Verbose = false }
ConnectOptions = ConnectOptions.Default with { Echo = true, Verbose = false },
PingInterval = TimeSpan.FromSeconds(5)
};




var connection = new NatsConnection(options);

await Parallel.ForEachAsync(Enumerable.Range(0, 100), new ParallelOptions { MaxDegreeOfParallelism = 100 }, async (i, ct) =>
{
var ttl = await connection.PingAsync();
Console.WriteLine(ttl);
});
Console.ReadLine();

await connection.PublishAsync("foo", 100);

await connection.SubscribeAsync<int>("foo", x =>
{
Console.WriteLine(x);
});

// Server
await connection.SubscribeRequestAsync<FooRequest, FooResponse>("hogemoge.key", req =>
{
Console.WriteLine("YEAH?");
return new FooResponse();
});

// Client
var response = await connection.RequestAsync<FooRequest, FooResponse>("hogemoge.key", new FooRequest());

await connection.ConnectAsync();


var ttl = await connection.PingAsync();
Console.WriteLine("RTT:" + ttl.TotalMilliseconds);

Console.ReadLine();


}

//static void CalcCommandPushPop(NatsKey key, INatsSerializer serializer)
Expand Down
Loading

0 comments on commit c3cb8ee

Please sign in to comment.