PubSubServer's linux issues fixed

This commit is contained in:
Taha committed 2024-06-23 21:13:37 -04:00
1 parent f93d28ee76
commit 87b6a2044c
54 files changed
+2920 -1464

No files matched your search

+12 -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;
@@ -24,8 +25,11 @@ int Run(PubSubServerConfig cfg) {
cfg.MergeWith(PubSubServerConfig.Default());
PubSubConfig.SetGlobalConfig(Log.notnull(cfg.PubSub));
Configuration.initialize(cfg.Sparkd);
bool run_echo_server = false;
bool echo_msg_back = false;
cfg.SimpleEchoServer = run_echo_server;
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.
@@ -58,11 +62,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) {