AsyncTCPConnection_APM works now

This commit is contained in:
Taha Afzal committed 2024-01-09 14:34:15 -05:00
1 parent 047267ad1b
commit 694f8b8d11
10 files changed
+611 -287

No files matched your search

@@ -11,9 +11,11 @@ using System.Threading;
bts.Log.Gen.info($"Starting DSPublisher");
Console.WriteLine("Starting DSPublisher...");
bool run_echo_tcp_client_only = false;
static void init(string[] args) {
Func<string, string, Task> login = async (l, p) => {
bool run_echo_tcp_client_only = true;
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();
@@ -29,26 +31,32 @@ if (run_echo_tcp_client_only)
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() {
async Task 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();
}
void _publish_streams() {
void _publish_streams()
{
PubTableBroker pb_broker = new PubTableBroker();
CloudStreamManager csm = new CloudStreamManager();
// get it from config
@@ -61,14 +69,16 @@ 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();
@@ -77,6 +87,7 @@ void _publish_streams() {
void on_change(object obj) {
void on_change(object obj)
{
bts.Log.Gen.info($"DSPublisher on_change dp: {obj}");
}