コード例 #1
0
        public IProvidedMethodReference CreateProvidedMethodReference(IProvidedServiceReference providedService, string methodId)
        {
            var obj = ProvidedMethodReference.Rent();

            obj.ProvidedService = providedService;
            obj.MethodId        = methodId;
            return(obj);
        }
コード例 #2
0
        private static ProvidedMethodReference ConvertToProtoStrict(IProvidedMethodReference obj)
        {
            var proto = ProvidedMethodReference.Rent();

            proto.ProvidedService = ConvertToProtoStrict(obj.ProvidedService);
            proto.MethodId        = obj.MethodId.ConvertToProtoStrict();
            return(proto);
        }
コード例 #3
0
 internal DiscoveredMethod(
     ProvidedMethodReference providedMethod,
     Maybe <string> title,
     string inputMessageId,
     string outputMessageId,
     MethodType type)
     : this(providedMethod, title, inputMessageId, outputMessageId, type, new MethodCallDescriptor(providedMethod))
 {
 }
コード例 #4
0
        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));
        }
コード例 #5
0
 internal DiscoveredOnlineMethod(
     ProvidedMethodReference providedMethod,
     Maybe <string> title,
     string inputMessageId,
     string outputMessageId,
     MethodType type)
     : base(
         providedMethod,
         title,
         inputMessageId,
         outputMessageId,
         type)
 {
     ProviderConnectionId = providedMethod.ProvidedService.ConnectionId.Value;
 }
コード例 #6
0
 internal DiscoveredMethod(
     ProvidedMethodReference providedMethod,
     Maybe <string> title,
     string inputMessageId,
     string outputMessageId,
     MethodType type,
     MethodCallDescriptor callDescriptor)
 {
     ProvidedMethod  = providedMethod;
     Title           = title;
     InputMessageId  = inputMessageId;
     OutputMessageId = outputMessageId;
     Type            = type;
     CallDescriptor  = callDescriptor;
 }
コード例 #7
0
        private void SubscribeToApplicationLaunchedEventStream(string applicationId, UniqueId connectionId)
        {
            var appLauncherServiceId           = AppLauncherService.Id;
            var appLaunchedEventStreamMethodId = AppLauncherService.AppLaunchedEventStreamMethodId;
            var methodCallDescriptor           = ProvidedMethodReference.Create(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(_appLaunchedSubject).ConfigureAwait(false);
                Log.Info($"Subscription to ApplicationLaunchedEventStream of {connectionId} application ({applicationId}) have finished");
            }, TaskCreationOptions.LongRunning);
        }
コード例 #8
0
        public async ValueTask <UniqueId> LaunchAsync(string appId)
        {
            Log.Info("Launching {0}", appId);

            if (string.Equals(appId, "interop.NativeAppLauncher"))
            {
                return((await _startNativeAppLauncherTask.Value.ConfigureAwait(false)).Id);
            }

            var appDto = _appsDto.Apps.FirstOrDefault(x => string.Equals(x.Id, appId));

            if (appDto == null)
            {
                throw new InvalidOperationException($"The requested application {appId} is not defined in application registry");
            }

            if (string.IsNullOrEmpty(appDto.LauncherId))
            {
                throw new InvalidOperationException($"Launcher is not defined for application {appId}");
            }

            var launchMethodReference =
                ProvidedMethodReference.Create("interop.AppLauncherService", "Launch", appDto.LauncherId);

            var response = await _client
                           .CallUnary <AppLaunchRequest, AppLaunchResponse>(
                launchMethodReference.CallDescriptor,
                new AppLaunchRequest
            {
                AppId            = appId,
                LaunchParamsJson = appDto.LauncherParams.ToString()
            })
                           .ConfigureAwait(false);

            var appInstanceId = UniqueId.FromHiLo(response.AppInstanceId.Hi, response.AppInstanceId.Lo);

            Log.Info("Launched app {0} instance {1}", appId, appInstanceId);

            return(appInstanceId);
        }
コード例 #9
0
 private IProvidedMethodReference ConvertFromProtoStrict(ProvidedMethodReference proto)
 {
     return(_messageFactory.CreateProvidedMethodReference(
                ConvertFromProtoStrict(proto.ProvidedService),
                proto.MethodId.ConvertFromProtoStrict()));
 }
コード例 #10
0
 public MethodCallDescriptor(ProvidedMethodReference method) : this(default, method)
 {
 }
コード例 #11
0
        private void SubscribeToLaunchedEventStream(AppLifecycleManagerClient client, UniqueId connectionId, string applicationId, ProvidedMethodReference methodCallDescriptor)
        {
            Task.Factory.StartNew(async() =>
            {
                Log.Info($"Subscribing client '{client.ApplicationInstanceId}' to ApplicationLaunchedEventStream of {connectionId} application ({applicationId})");

                await client.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);
        }