Esempio n. 1
0
        public RpcServerTask(ITaskManager taskManager,
                             IProcessManager processManager,
                             IProcessEnvironment processEnvironment,
                             IEnvironment environment,
                             IRpcProcessConfiguration configuration,
                             string workingDir             = default,
                             ProcessOptions options        = default,
                             PortOutputProcessor processor = null,
                             List <Type> remoteRpcTargets  = null, List <object> localRpcTargets = null,
                             CancellationToken token       = default)
            : base(taskManager, token)
        {
            this.expectedPort       = configuration.Port;
            this.processManager     = processManager;
            this.configuration      = configuration;
            this.workingDir         = workingDir;
            this.options            = options;
            this.processEnvironment = processManager.DefaultProcessEnvironment;
            this.environment        = processEnvironment.Environment;
            this.remoteRpcTargets   = remoteRpcTargets ?? new List <Type>();
            this.localRpcTargets    = localRpcTargets ?? new List <object>();
            executable = configuration.ExecutablePath;
            arguments  = CreateArguments(environment, configuration);

            portProcessor = processor ?? new PortOutputProcessor();
        }
Esempio n. 2
0
        public ProcessServer(ITaskManager taskManager,
                             IEnvironment environment,
                             IRpcProcessConfiguration configuration)
        {
            Environment    = environment;
            completionTask = completionHandle.ToTask();

            ownsTaskManager = taskManager == null;

            if (ownsTaskManager)
            {
                taskManager = new TaskManager();
                try
                {
                    taskManager.Initialize();
                }
                catch
                {
                    ourContext = new MainThreadSynchronizationContext(cts.Token);
                    taskManager.Initialize(ourContext);
                }
            }
            else
            {
                externalCts = CancellationTokenSource.CreateLinkedTokenSource(taskManager.Token);
                externalCts.Token.Register(Dispose);
            }

            TaskManager = taskManager;

            if (configuration == null)
            {
                configuration = new ApplicationConfigurationWrapper(TaskManager, ApplicationConfiguration.instance);
                // read the executable path up front so it gets serialized if it needs to, while we're on the main thread
                var _ = configuration.ExecutablePath;
            }

            if (string.IsNullOrEmpty(configuration.AccessToken))
            {
                configuration.AccessToken = GenerateAccessToken();
            }

            Configuration = configuration;

            localProcessManager = new ProcessManager(Environment);
            processManager      = new RemoteProcessManager(this, localProcessManager.DefaultProcessEnvironment, cts.Token);
            notifications       = new ServerNotifications(this);

#if UNITY_EDITOR
            UnityEditor.EditorApplication.quitting += ShutdownSync;
#endif
        }
Esempio n. 3
0
 public RpcServerTask(ITaskManager taskManager,
                      IProcessManager processManager,
                      IRpcProcessConfiguration configuration,
                      string workingDir             = default,
                      ProcessOptions options        = default,
                      PortOutputProcessor processor = null,
                      List <Type> remoteRpcTargets  = null, List <object> localRpcTargets = null,
                      CancellationToken token       = default)
     : this(taskManager, processManager, processManager.DefaultProcessEnvironment,
            processManager.DefaultProcessEnvironment.Environment,
            configuration, workingDir, options, processor, remoteRpcTargets, localRpcTargets, token)
 {
 }
Esempio n. 4
0
        private static string CreateArguments(IEnvironment environment, IRpcProcessConfiguration configuration)
        {
            var args = new List <string>();

            args.Add("-projectPath");
            args.Add(environment.UnityProjectPath.ToSPath().InQuotes());
            args.Add("-pid");
            args.Add(System.Diagnostics.Process.GetCurrentProcess().Id.ToString());
            if (!string.IsNullOrEmpty(configuration.AccessToken))
            {
                args.Add("-accessToken");
                args.Add(configuration.AccessToken);
            }
            return(string.Join(" ", args));
        }
Esempio n. 5
0
        public static IProcessServer Get(ITaskManager taskManager = null,
                                         IEnvironment environment = null,
                                         IRpcProcessConfiguration configuration = null)
        {
            if (instance?.disposed ?? false)
            {
                instance = null;
            }

            if (instance == null)
            {
                var inst = new ProcessServer(taskManager, environment ?? TheEnvironment.instance.Environment, configuration);
                instance = inst;
            }
            return(instance);
        }
Esempio n. 6
0
 public ApplicationConfigurationWrapper(ITaskManager taskManager, IRpcProcessConfiguration other)
 {
     this.taskManager = taskManager;
     this.other       = other;
 }
 public TestProcessServer(ITaskManager taskManager,
                          IEnvironment environment,
                          IRpcProcessConfiguration configuration)
     : base(taskManager, environment, configuration)
 {
 }