/// <summary>
        /// Handle a change in session state
        /// </summary>
        void connector_OnSessionStateChangeEvent(object sender, SessionStateChangeEventArgs e)
        {
            VoiceSession s;

            switch (e.State)
            {
            case VoiceGateway.SessionState.Connected:
                s              = FindSession(e.SessionHandle, true);
                sessionHandle  = e.SessionHandle;
                s.RegionName   = regionName;
                spatialSession = s;

                Logger.Log("Voice connected in " + regionName, Helpers.LogLevel.Info);
                // Tell any user-facing code.
                if (OnSessionCreate != null)
                {
                    OnSessionCreate(s, null);
                }
                break;

            case VoiceGateway.SessionState.Disconnected:
                s = FindSession(sessionHandle, false);
                sessions.Remove(sessionHandle);

                if (s != null)
                {
                    Logger.Log("Voice disconnected in " + s.RegionName, Helpers.LogLevel.Info);

                    // Inform interested parties
                    if (OnSessionRemove != null)
                    {
                        OnSessionRemove(s, null);
                    }

                    if (s == spatialSession)
                    {
                        spatialSession = null;
                    }
                }

                // The previous session is now ended.  Check for a new one and
                // start it going.
                if (nextParcelCap != null)
                {
                    currentParcelCap = nextParcelCap;
                    nextParcelCap    = null;
                    RequestParcelInfo(currentParcelCap);
                }
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handle a change in session state
        /// </summary>
        void connector_OnSessionStateChangeEvent(object sender, SessionStateChangeEventArgs e)
        {
            VoiceSession s;

            switch (e.State)
            {
                case VoiceGateway.SessionState.Connected:
                    s = FindSession(e.SessionHandle, true);
                    sessionHandle = e.SessionHandle;
                    s.RegionName = regionName;
                    spatialSession = s;

                    Logger.Log("Voice connected in " + regionName, Helpers.LogLevel.Info);
                    // Tell any user-facing code.
                    if (OnSessionCreate != null)
                        OnSessionCreate(s, null);
                    break;

                case VoiceGateway.SessionState.Disconnected:
                    s = FindSession(sessionHandle, false);
                    sessions.Remove(sessionHandle);

                    if (s != null)
                    {
                        Logger.Log("Voice disconnected in " + s.RegionName, Helpers.LogLevel.Info);

                        // Inform interested parties
                        if (OnSessionRemove != null)
                            OnSessionRemove(s, null);

                        if (s == spatialSession)
                            spatialSession = null;
                    }

                    // The previous session is now ended.  Check for a new one and
                    // start it going.
                    if (nextParcelCap != null)
                    {
                        currentParcelCap = nextParcelCap;
                        nextParcelCap = null;
                        RequestParcelInfo(currentParcelCap);
                    }
                    break;
            }
        }