Example #1
0
        private void CreateProtocols(FileSystemPath portFileFullPath)
        {
            if (!portFileFullPath.ExistsFile)
            {
                return;
            }

            var text = File.ReadAllText(portFileFullPath.FullPath);

            if (!int.TryParse(text, out var port))
            {
                myLogger.Error("Couldn't parse port for from file:{0}, text:{1}", portFileFullPath, text);
                return;
            }

            var modelLifetime = myConnectionLifetimeProducer.Next();

            myLogger.Info("Creating SocketWire with port = {0}", port);
            var wire = new SocketWire.Client(modelLifetime, myDispatcher, port, "UnrealEditorClient");

            wire.Connected.Advise(modelLifetime, isConnected => myUnrealHost.PerformModelAction(riderModel =>
                                                                                                riderModel.IsConnectedToUnrealEditor.SetValue(isConnected)));

            var protocol = new Protocol("UnrealEditorPlugin", new Serializers(),
                                        new Identities(IdKind.Client), myDispatcher, wire, modelLifetime);

            wire.Connected.WhenTrue(modelLifetime, lifetime =>
            {
                myLogger.Info("Wire connected");
                ResetModel(lifetime, protocol);
            });
        }
 private void BindToNotificationFixAction()
 {
     myUnrealHost.PerformModelAction(model =>
     {
         model.InstallEditorPlugin.AdviseNotNull(myLifetime, unit =>
         {
             myShellLocks.ExecuteOrQueueReadLockEx(myLifetime,
                                                   "UnrealPluginInstaller.CheckAllProjectsIfAutoInstallEnabled",
                                                   InstallPluginIfInfoAvailable);
         });
     });
 }
        public UnrealPluginInstaller(Lifetime lifetime, ILogger logger, UnrealPluginDetector pluginDetector,
                                     PluginPathsProvider pathsProvider, ISolution solution, ISettingsStore settingsStore,
                                     IShellLocks shellLocks, UnrealHost unrealHost)
        {
            myLifetime           = lifetime;
            myLogger             = logger;
            myPathsProvider      = pathsProvider;
            myShellLocks         = shellLocks;
            myUnrealHost         = unrealHost;
            myBoundSettingsStore = settingsStore.BindToContextLive(myLifetime, ContextRange.Smart(solution.ToDataContext()));
            myPluginDetector     = pluginDetector;

            myPluginDetector.InstallInfoProperty.Change.Advise_NewNotNull(myLifetime, installInfo =>
            {
                myShellLocks.ExecuteOrQueueReadLockEx(myLifetime, "UnrealPluginInstaller.CheckAllProjectsIfAutoInstallEnabled",
                                                      () =>
                {
                    var unrealPluginInstallInfo = installInfo.New;
                    if (unrealPluginInstallInfo.EnginePlugin.IsPluginAvailable)
                    {
                        // TODO: add install plugin to Engine
                    }
                    ;

                    if (!myBoundSettingsStore.GetValue((UnrealLinkSettings s) => s.InstallRiderLinkPlugin))
                    {
                        foreach (var installDescription in unrealPluginInstallInfo.ProjectPlugins)
                        {
                            if (installDescription.IsPluginAvailable == false ||
                                installDescription.PluginVersion != myPathsProvider.CurrentPluginVersion)
                            {
                                myUnrealHost.PerformModelAction(model => model.OnEditorModelOutOfSync());
                            }
                        }

                        return;
                    }

                    InstallPluginIfRequired(unrealPluginInstallInfo);
                });
            });
            BindToInstallationSettingChange();
            BindToNotificationFixAction();
        }