/// <summary> /// Connect to a running instance of Houdini with SessionSync enabled. /// </summary> void ConnectSessionSync(HEU_SessionSyncData syncData) { if (syncData != null && syncData.SyncStatus != HEU_SessionSyncData.Status.Stopped) { return; } Log("Connecting To Houdini..."); HEU_SessionManager.RecreateDefaultSessionData(); if (syncData == null) { HEU_SessionData sessionData = HEU_SessionManager.GetSessionData(); if (sessionData != null) { syncData = sessionData.GetOrCreateSessionSync(); } else { syncData = new HEU_SessionSyncData(); } } bool result = InternalConnect(_sessionMode, _pipeName, HEU_PluginSettings.Session_Localhost, _port, HEU_PluginSettings.Session_AutoClose, HEU_PluginSettings.Session_Timeout, true); if (result) { try { HEU_SessionManager.InitializeDefaultSession(); HEU_SessionManager.GetDefaultSession().GetSessionData().SetSessionSync(syncData); syncData.SyncStatus = HEU_SessionSyncData.Status.Connected; Log("Connected!"); } catch (HEU_HoudiniEngineError ex) { syncData.SyncStatus = HEU_SessionSyncData.Status.Stopped; Log("Connection errored!"); Log(ex.ToString()); } } else { Log("Connection failed!"); } }
/// <summary> /// Launch Houdini with SessionSync enabled and automatically connect to it. /// </summary> void StartAndConnectToHoudini(HEU_SessionSyncData syncData) { if (syncData != null && syncData.SyncStatus != HEU_SessionSyncData.Status.Stopped) { return; } if (!OpenHoudini()) { return; } // Now attempt to connect to it by moving into Connecting state HEU_SessionManager.RecreateDefaultSessionData(); if (syncData == null) { HEU_SessionData sessionData = HEU_SessionManager.GetSessionData(); if (sessionData != null) { syncData = sessionData.GetOrCreateSessionSync(); } else { syncData = new HEU_SessionSyncData(); } syncData._validForConnection = true; } syncData.SyncStatus = HEU_SessionSyncData.Status.Connecting; _connectionSyncData = syncData; Log("Connecting..."); syncData._timeStartConnection = Time.realtimeSinceStartup; syncData._timeLastUpdate = Time.realtimeSinceStartup; }