private void ConnectPubSub() { #if !NET35 if (string.IsNullOrEmpty(PubSubTopic)) { return; } if (_pubsubCancellationTokenSource != null) { return; // already or still running } _pubsubCancellationTokenSource = new CancellationTokenSource(); TheBaseEngine.WaitForEnginesStartedAsync().Wait(); TheBaseEngine.WaitForStorageReadinessAsync(true).Wait(); var comLine = Operator.GetLine(MyBaseThing); _subscriber = new Subscriber(comLine, _pubsubCancellationTokenSource.Token); //if (!string.IsNullOrEmpty(PubSubAckTopic)) { //var catchAllSubscription = _subscriber.Subscribe("*"); _subscriber.Subscribe(PubSubTopic) .With((time, channel, message) => { ProcessPubSubMessage(time, channel, message); }); } _publisher = new Publisher(comLine, _pubsubCancellationTokenSource.Token); _publisher.ConnectAsync().ContinueWith(t => t.Result.Publish("public:debug", $"Publisher {MyBaseThing.FriendlyName} initialized")); #endif }