InitializeDefaultSession() публичный статический Метод

public static InitializeDefaultSession ( ) : bool
Результат bool
Пример #1
0
        /// <summary>
        /// Attempts to connect to running instance of Houdini with SessionSync enabled,
        /// with CONNECTION_ATTEMPT_RATE delay between attempts. Presuming that Houdini was just,
        /// launched this might take a few tries. Times out if unsuccessful after CONNECTION_TIME_OUT
        /// time.
        /// </summary>
        void UpdateConnecting(HEU_SessionSyncData syncData)
        {
            if (syncData == null || syncData.SyncStatus != HEU_SessionSyncData.Status.Connecting)
            {
                return;
            }

            // Attempt connection after waiting for a bit.
            if (Time.realtimeSinceStartup - syncData._timeLastUpdate >= CONNECTION_ATTEMPT_RATE)
            {
                if (InternalConnect(_sessionMode, _pipeName,
                                    HEU_PluginSettings.Session_Localhost, _port,
                                    HEU_PluginSettings.Session_AutoClose,
                                    HEU_PluginSettings.Session_Timeout, false))
                {
                    Log("Initializing...");
                    syncData.SyncStatus = HEU_SessionSyncData.Status.Initializing;

                    try
                    {
                        HEU_SessionManager.InitializeDefaultSession();
                        HEU_SessionManager.GetDefaultSession().GetSessionData().SetSessionSync(syncData);

                        syncData.SyncStatus = HEU_SessionSyncData.Status.Connected;
                        Log("Connected!");
                    }
                    catch (System.Exception ex)
                    {
                        syncData.SyncStatus = HEU_SessionSyncData.Status.Stopped;
                        Log("Connection errored!");
                        Log(ex.ToString());

                        Debug.Log(ex.ToString());
                    }
                    finally
                    {
                        // Clear this to get out of the connection state
                        _connectionSyncData = null;
                    }
                }
                else if (Time.realtimeSinceStartup - syncData._timeStartConnection >= CONNECTION_TIME_OUT)
                {
                    syncData.SyncStatus = HEU_SessionSyncData.Status.Stopped;
                    Log("Timed out trying to connect to Houdini."
                        + "\nCheck if Houdini is running and SessionSync is enabled."
                        + "\nCheck port or pipe name are correct by comparing with Houdini SessionSync panel.");
                }
                else
                {
                    // Try again in a bit
                    syncData._timeLastUpdate = Time.realtimeSinceStartup;
                }
            }
        }
Пример #2
0
        /// <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!");
            }
        }