private void OnAppConnected(AppConnectionDescriptor appConnectionDescriptor) { if (IsLauncher(appConnectionDescriptor, out var applicationId)) { SubscribeToApplicationLaunchedEventStream(applicationId, appConnectionDescriptor.ConnectionId); } }
private static Generated.AppConnectionDescriptor ConvertToProto(AppConnectionDescriptor connection) { return(new Generated.AppConnectionDescriptor { AppInstanceId = connection.ApplicationInstanceId.ToProto(), AppId = connection.ApplicationId, ConnectionId = connection.ConnectionId.ToProto(), }); }
public async Task <ResolveAppResponse> ResolveApp(ResolveAppRequest request, MethodCallContext context) { Log.Info("Resolving app by request {{{0}}} from {{{1}}}", request, context); var referrerConnectionInfo = new AppConnectionDescriptor( context.ConsumerConnectionId, context.ConsumerApplicationId, context.ConsumerApplicationInstanceId, context.ConsumerTransportType); var resolveMode = Convert(request.AppResolveMode); if (resolveMode == ResolveMode.SingleInstance) { var connection = _appLifecycleManager.GetOnlineConnections().FirstOrDefault(c => c.Info.ApplicationId.Equals(request.AppId)); Log.Debug("Resolved connection for app {0} with mode {1} to online instance {{{2}}}", connection, resolveMode, connection); if (connection != null) { return(new ResolveAppResponse { AppInstanceId = connection.Info.ApplicationInstanceId.ToProto(), AppConnectionId = connection.Info.ConnectionId.ToProto(), IsNewInstanceLaunched = false, }); } } var resolvedConnection = await _appLifecycleManager.LaunchAndConnectAsync( request.AppId, resolveMode, referrerConnectionInfo).ConfigureAwait(false); var info = resolvedConnection.AppConnection.Info; Log.Info("App connection {{{0}}} resolved by request from {{{1}}}", resolvedConnection, context); var response = new ResolveAppResponse { AppConnectionId = info.ConnectionId.ToProto(), AppInstanceId = info.ApplicationInstanceId.ToProto(), IsNewInstanceLaunched = resolvedConnection.IsNewInstance }; return(response); }
private static bool IsEventFitRequest(GetConnectionsRequest request, AppConnectionDescriptor connection) { var connectionId = request.ConnectionId.ToUniqueId(); if (connectionId != UniqueId.Empty) { return(connectionId.Equals(connection.ConnectionId)); } var appId = request.ApplicationId; var appInstanceId = request.AppInstanceId.ToUniqueId(); if (appInstanceId != UniqueId.Empty && !connection.ApplicationInstanceId.Equals(appInstanceId)) { return(false); } if (!string.IsNullOrEmpty(appId) && !connection.ApplicationId.Equals(appId)) { return(false); } return(true); }
private bool IsLauncher(AppConnectionDescriptor appConnectionDescriptor, out string applicationId) { applicationId = appConnectionDescriptor.ApplicationId; return(_registryProvider.Current.Applications.TryGetValue(applicationId, out var application) && application.ProvidedServices.Any(service => service.Service.Id == AppLauncherService.Id)); }