internal WSConnector(ProtocolInstance instance, IceInternal.Connector del, string host, string resource) { _instance = instance; _delegate = del; _host = host; _resource = resource; }
private static void InitializeProtocol(Lifetime lifetime, string protocolInstancePath) { var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); var solutionNames = new List <string>() { currentDirectory.Name }; var solutionFiles = currentDirectory.GetFiles("*.sln", SearchOption.TopDirectoryOnly); foreach (var solutionFile in solutionFiles) { var solutionName = Path.GetFileNameWithoutExtension(solutionFile.FullName); if (!solutionName.Equals(currentDirectory.Name)) { solutionNames.Add(solutionName); } } var protocols = new List <ProtocolInstance>(); // if any protocol connection losts, we will drop all protocol and recreate them var allProtocolsLifetimeDefinition = lifetime.CreateNested(); foreach (var solutionName in solutionNames) { var port = CreateProtocolForSolution(allProtocolsLifetimeDefinition.Lifetime, solutionName, () => { allProtocolsLifetimeDefinition.Terminate(); }); if (port == -1) { continue; } protocols.Add(new ProtocolInstance(solutionName, port)); } allProtocolsLifetimeDefinition.Lifetime.OnTermination(() => { if (Lifetime.IsAlive) { ourLogger.Verbose("Recreating protocol, project lifetime is alive"); InitializeProtocol(lifetime, protocolInstancePath); } else { ourLogger.Verbose("Protocol will be recreating on next domain load, project lifetime is not alive"); } }); var result = ProtocolInstance.ToJson(protocols); File.WriteAllText(protocolInstancePath, result); }
public static void Init() { if (ourInitialized) { return; } var projectDirectory = Directory.GetParent(Application.dataPath).FullName; var projectName = Path.GetFileName(projectDirectory); SlnFile = Path.GetFullPath($"{projectName}.sln"); InitializeEditorInstanceJson(); var lifetimeDefinition = Lifetime.Define(Lifetime.Eternal); var lifetime = lifetimeDefinition.Lifetime; AppDomain.CurrentDomain.DomainUnload += (EventHandler)((_, __) => { ourLogger.Verbose("lifetimeDefinition.Terminate"); lifetimeDefinition.Terminate(); }); if (PluginSettings.SelectedLoggingLevel >= LoggingLevel.VERBOSE) { var executingAssembly = Assembly.GetExecutingAssembly(); var location = executingAssembly.Location; Debug.Log($"Rider plugin \"{executingAssembly.GetName().Name}\" initialized{(string.IsNullOrEmpty(location)? "" : " from: " + location )}. LoggingLevel: {PluginSettings.SelectedLoggingLevel}. Change it in Unity Preferences -> Rider. Logs path: {LogPath}."); } var list = new List <ProtocolInstance>(); CreateProtocolAndAdvise(lifetime, list, new DirectoryInfo(Directory.GetCurrentDirectory()).Name); // list all sln files in CurrentDirectory, except main one and create server protocol for each of them var currentDir = new DirectoryInfo(Directory.GetCurrentDirectory()); var solutionFiles = currentDir.GetFiles("*.sln", SearchOption.TopDirectoryOnly); foreach (var solutionFile in solutionFiles) { if (Path.GetFileNameWithoutExtension(solutionFile.FullName) != currentDir.Name) { CreateProtocolAndAdvise(lifetime, list, Path.GetFileNameWithoutExtension(solutionFile.FullName)); } } OpenAssetHandler = new OnOpenAssetHandler(ourRiderPathProvider, ourPluginSettings, SlnFile); ourLogger.Verbose("Writing Library/ProtocolInstance.json"); var protocolInstanceJsonPath = Path.GetFullPath("Library/ProtocolInstance.json"); File.WriteAllText(protocolInstanceJsonPath, ProtocolInstance.ToJson(list)); AppDomain.CurrentDomain.DomainUnload += (sender, args) => { ourLogger.Verbose("Deleting Library/ProtocolInstance.json"); File.Delete(protocolInstanceJsonPath); }; PlayModeSavedState = GetPlayModeState(); ourInitialized = true; }
private static void Init() { var projectDirectory = Directory.GetParent(Application.dataPath).FullName; var projectName = Path.GetFileName(projectDirectory); SlnFile = Path.GetFullPath($"{projectName}.sln"); InitializeEditorInstanceJson(); ResetDefaultFileExtensions(); // process csproj files once per Unity process if (!RiderScriptableSingleton.Instance.CsprojProcessedOnce) { EditorApplication.update += SyncSolutionOnceCallBack; } var lifetimeDefinition = Lifetimes.Define(EternalLifetime.Instance); var lifetime = lifetimeDefinition.Lifetime; AppDomain.CurrentDomain.DomainUnload += (EventHandler)((_, __) => { ourLogger.Verbose("lifetimeDefinition.Terminate"); lifetimeDefinition.Terminate(); }); if (PluginSettings.SelectedLoggingLevel >= LoggingLevel.VERBOSE) { Debug.Log($"Rider plugin initialized. LoggingLevel: {PluginSettings.SelectedLoggingLevel}. Change it in Unity Preferences -> Rider. Logs path: {LogPath}."); } var list = new List <ProtocolInstance>(); CreateProtocolAndAdvise(lifetime, list, new DirectoryInfo(Directory.GetCurrentDirectory()).Name); // list all sln files in CurrentDirectory, except main one and create server protocol for each of them var currentDir = new DirectoryInfo(Directory.GetCurrentDirectory()); var solutionFiles = currentDir.GetFiles("*.sln", SearchOption.TopDirectoryOnly); foreach (var solutionFile in solutionFiles) { if (Path.GetFileNameWithoutExtension(solutionFile.FullName) != currentDir.Name) { CreateProtocolAndAdvise(lifetime, list, Path.GetFileNameWithoutExtension(solutionFile.FullName)); } } ourOpenAssetHandler = new OnOpenAssetHandler(ourRiderPathLocator, ourPluginSettings, SlnFile); ourLogger.Verbose("Writing Library/ProtocolInstance.json"); var protocolInstanceJsonPath = Path.GetFullPath("Library/ProtocolInstance.json"); File.WriteAllText(protocolInstanceJsonPath, ProtocolInstance.ToJson(list)); AppDomain.CurrentDomain.DomainUnload += (sender, args) => { ourLogger.Verbose("Deleting Library/ProtocolInstance.json"); File.Delete(protocolInstanceJsonPath); }; PlayModeSavedState = GetEditorState(); SetupAssemblyReloadEvents(); ourInitialized = true; }
internal WSAcceptor(WSEndpoint endpoint, ProtocolInstance instance, Acceptor del) { _endpoint = endpoint; _instance = instance; _delegate = del; }