Add echoDelay param to SimpleTCPServer

This commit is contained in:
John Colvin committed 2024-03-05 12:51:16 -06:00
1 parent 6f931a1b0c
commit a8b2eab935
4 files changed
+26 -8

No files matched your search

+4 -3
View File
@@ -17,9 +17,10 @@ Parser.Default.ParseArguments<PubSubServerConfig>(args)
int Run(PubSubServerConfig cfg) {
try {
cfg.MergeWithConfigFile();
Configuration.initialize();
return cfg.SimpleEchoServer ?? false ?
RunEchoServer(cfg.Port ?? 12345) :
RunEchoServer(cfg.Port ?? 12345, cfg.EchoDelay) :
RunPubSubServer(cfg);
} catch (Exception ex) {
// Write the error to console first, in case the logging system is compromised.
@@ -52,11 +53,11 @@ int RunPubSubServer(PubSubServerConfig cfg) {
return 0;
}
int RunEchoServer(short port) {
int RunEchoServer(short port, TimeSpan? echoDelay) {
Console.WriteLine("Running as TCP Echo server, Hit enter to continue");
Console.ReadLine();
Console.WriteLine($"ready to listen to port: {port}");
var sts = new SimpleTCPServer(port);
var sts = new SimpleTCPServer(port, echoDelay);
sts.init();
Console.CancelKeyPress += OnCancelKeyPress;
while (true) {