Adding AsyncTCPConnectionAcceptor_APM and AsyncTCPConnector_APM to create ITCPConnection

This commit is contained in:
Taha Afzal committed 2024-01-11 16:10:51 -05:00
1 parent 694f8b8d11
commit d50e8cda50
11 files changed
+719 -576

No files matched your search

@@ -12,10 +12,8 @@ using System.Threading;
bts.Log.Gen.info($"Starting DSPublisher");
Console.WriteLine("Starting DSPublisher...");
bool run_echo_tcp_client_only = true;
static void init(string[] args)
{
Func<string, string, Task> login = async (l, p) =>
{
static void init(string[] args) {
Func<string, string, Task> login = async (l, p) => {
var login = l;
var passwd = p;
var service_ctx = bts.api.core.ServiceContext.create();
@@ -27,36 +25,35 @@ static void init(string[] args)
}
init(args);
if (run_echo_tcp_client_only)
await start_echo_client();
start_echo_client();
else
_publish_streams();
static ViewStream build_stream(string stream_expression)
{
try
{
static ViewStream build_stream(string stream_expression) {
try {
var exp = DataStreamExpressionsInterpreter.Evaluate(stream_expression);
var rv = exp.getView(new Dictionary<string, StatementExpression>(0));
return rv;
}
catch (Exception ex)
{
} catch (Exception ex) {
bts.Log.assert(false, $"Could not build stream: {stream_expression} ex: {ex}");
return null;
}
}
async Task start_echo_client()
{
static void start_echo_client() {
Console.WriteLine("Starting DSPublisher in TCP client echo mode, Hit key to continue");
Console.ReadLine();
await SimpleTCPClientAsync.start("127.0.0.1", 12345);
Task.Delay(1000000000).Wait();
SimpleTCPClient client = new SimpleTCPClient("127.0.0.1", 12345);
client.start();
while (true) {
System.Threading.Thread.Sleep(1000);
}
// await SimpleTCPClient.start("127.0.0.1", 12345);
// Task.Delay(1000000000).Wait();
}
void _publish_streams()
{
void _publish_streams() {
PubTableBroker pb_broker = new PubTableBroker();
CloudStreamManager csm = new CloudStreamManager();
// get it from config
@@ -69,16 +66,14 @@ void _publish_streams()
{"literal_420","literal(\"x\", \"420.0\")"},
// {"bbo_ts","timeSeries(bbo())"}
};
foreach (var kv in streams_to_publish)
{
foreach (var kv in streams_to_publish) {
var name = kv.Key;
var exp = kv.Value;
BCG.ViewStream vs = build_stream(exp);
ViewPublisher vpub = new ViewPublisher(name, pb_broker, vs);
vs.onChange += on_change;
}
while (true)
{
while (true) {
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
ViewStreamDatabase.instance.doWork();
csm.doWork();
@@ -87,7 +82,6 @@ void _publish_streams()
void on_change(object obj)
{
void on_change(object obj) {
bts.Log.Gen.info($"DSPublisher on_change dp: {obj}");
}