public void WithLiveStreamer_ShouldSubscribeToAChannelAndMakeCallback() { var isCallBack = false; var channelCreationResult = _eventLiveStreamer.CreateChannel(name: "Test", fifo: true, maxLifeTimeSubscriber: 30, maxLifeTimeMessage: 30).Result; channelCreationResult.Should().NotBeNull(); channelCreationResult.IsSuccessful.Should().BeTrue(); var channelSubscriptionResult = _eventLiveStreamer.Subscribe(channelName: "Test", callBackAction: new AsyncEventMethodCallBack( (message) => { message.Should().NotBeNull(); isCallBack = true; })).Result; channelSubscriptionResult.Should().NotBeNull(); channelSubscriptionResult.IsSuccessful.Should().BeTrue(); var channelPublishResult = _eventLiveStreamer.Publish(channelName: "Test", content: JsonConvert.SerializeObject(new { label = "test" })).Result; channelPublishResult.Should().NotBeNull(); channelPublishResult.IsSuccessful.Should().BeTrue(); isCallBack.Should().BeTrue(); }
public override async Task StartAsync(CancellationToken cancellationToken) { if (_eventLiveStreamer != null) { var executionResult = await _eventLiveStreamer.Subscribe(_channelName, _settings.CallBackType); if (executionResult.IsSuccessful) { _subscription = executionResult.Result; await Task.Factory.StartNew(() => ExecuteAsync(cancellationToken), cancellationToken); } else { throw new PlatformNotSupportedException(); } } }