PubSubServer's linux issues fixed

This commit is contained in:
Taha authored and John Colvin committed 2024-07-07 10:23:12 -04:00
1 parent 5cf7eacd82
commit 46bc00ce87
53 files changed
+2913 -1463

No files matched your search

+10 -5
View File
@@ -12,6 +12,7 @@ using mbts.config;
using Spark.Core;
using System;
using System.Collections.Specialized;
using System.Threading;
using System.Threading.Tasks;
@@ -25,8 +26,9 @@ int Run(PubSubServerConfig cfg) {
PubSubConfig.SetGlobalConfig(Log.notnull(cfg.PubSub));
Configuration.initialize(cfg.Sparkd);
Log.Gen.info("Starting PubSubServer");
bool echo_msg_back = false;
return cfg.SimpleEchoServer ?? false ?
RunEchoServer(cfg.PubSub.ServerPort.assert_value()) :
RunEchoServer(cfg.PubSub.ServerPort.assert_value(), echo_msg_back) :
RunPubSubServer();
} catch (Exception ex) {
// Write the error to console first, in case the logging system is compromised.
@@ -59,11 +61,14 @@ int RunPubSubServer() {
return 0;
}
int RunEchoServer(short port) {
Console.WriteLine("Running as TCP Echo server, Hit enter to continue");
int RunEchoServer(short port, bool echo) {
string log_msg = $"Running as TCP Echo server, port: {port} echo: {echo} Hit enter to continue:";
Console.WriteLine(log_msg);
Console.ReadLine();
Console.WriteLine($"ready to listen to port: {port}");
var sts = new SimpleTCPServer(port, true);
var ready_msg = $"ready to listen to port: {port}";
Log.Gen.info(ready_msg);
Console.WriteLine(ready_msg);
var sts = new SimpleTCPServer(port, echo);
sts.init();
Console.CancelKeyPress += OnCancelKeyPress;
while (true) {