refactor: Decouple ManagedSubscriber from ISubscriberCore impl

This commit is contained in:
John Colvin committed 2024-11-25 15:26:57 +00:00
1 parent 1cecbe9276
commit a5a905e20f
1 file changed
+6 -2
@@ -5,6 +5,7 @@ using System.Linq;
using BCG.Utilities.General;
using Bts.PubSub;
using OnData = System.Action<string, byte[]>;
@@ -18,7 +19,7 @@ namespace BCG {
/// </summary>
public class ManagedSubscriber : IWorker, IDisposable {
private static ManagedSubscriber? _self;
private SubscriberCore _subcore;
private ISubscriberCore _subcore;
// private IDictionary myTypedDispatchTable = new Hashtable(),
// myRawDispatchTable = new Hashtable();
private Dictionary<string, List<OnData>> _dispatch_table = new Dictionary<string, List<OnData>>();
@@ -26,7 +27,7 @@ namespace BCG {
public ManagedSubscriber() : this(new SubscriberCore()) { }
public ManagedSubscriber(SubscriberCore subsCore) { _subcore = subsCore; }
public ManagedSubscriber(ISubscriberCore subsCore) { _subcore = subsCore; }
public void doWork() {
var msg_map = new Dictionary<string, List<bts.PubSubServerMessage>>();
@@ -82,6 +83,9 @@ namespace BCG {
}
}
void IManagedSubscriber.Subscribe(string tag, OnData onData) =>
subscribe(tag, onData);
private void _fire_events(IEnumerable<bts.PubSubServerMessage> updates) {
// TODO
foreach (var u in updates) {