private void SubscribeToApplicationLaunchedEventStream(string applicationId, UniqueId connectionId) { var appLauncherServiceId = AppLauncherService.Id; var appLaunchedEventStreamMethodId = AppLauncherService.AppLaunchedEventStreamMethodId; var methodCallDescriptor = ProvidedMethodReference.CreateWithConnectionId(appLauncherServiceId, appLaunchedEventStreamMethodId, applicationId, connectionId); _lifecycleManagerClientRepo.GetClientObservable() .Subscribe(client => SubscribeToLaunchedEventStream(client, connectionId, applicationId, methodCallDescriptor)); }
private void SubscribeToApplicationLaunchedEventStream(string applicationId, UniqueId connectionId) { var appLauncherServiceId = AppLauncherService.Id; var appLaunchedEventStreamMethodId = AppLauncherService.AppLaunchedEventStreamMethodId; var methodCallDescriptor = ProvidedMethodReference.CreateWithConnectionId(appLauncherServiceId, appLaunchedEventStreamMethodId, applicationId, connectionId); Task.Factory.StartNew(async() => { Log.Info($"Subscribing to ApplicationLaunchedEventStream of {connectionId} application ({applicationId})"); await _client.Value.CallInvoker .CallServerStreaming <Empty, AppLaunchedEvent>(methodCallDescriptor.CallDescriptor, new Empty()) .ResponseStream.PipeAsync(_appLaunchedEventConsumer.AppLaunchedEventObserver).ConfigureAwait(false); Log.Info($"Subscription to ApplicationLaunchedEventStream of {connectionId} application ({applicationId}) have finished"); }, TaskCreationOptions.LongRunning); }