Esempio n. 1
0
        void gateway_OnSessionRemove(object sender, EventArgs e)
        {
            VoiceSession s = sender as VoiceSession;
            if (s == null) return;

            s.OnParticipantAdded -= new EventHandler(session_OnParticipantAdded);
            s.OnParticipantRemoved -= new EventHandler(session_OnParticipantRemoved);
            s.OnParticipantUpdate -= new EventHandler(session_OnParticipantUpdate);

            if (session != s) return;

            BeginInvoke(new MethodInvoker(delegate()
             {
                 participants.Clear();

                 if (gateway != null)
                 {
                     gateway.MicMute = true;
                 }
                 micMute.Checked = true;

                 session = null;
             }));
        }
Esempio n. 2
0
 private void Stop()
 {
     participants.Clear();
     gateway.Stop();
     UnregisterClientEvents();
     session = null;
     gateway = null;
     SetProgress(VoiceGateway.ConnectionState.None);
     GC.Collect();
 }
Esempio n. 3
0
        /// <summary>
        /// Locate a Session context from its handle
        /// </summary>
        /// <remarks>Creates the session context if it does not exist.</remarks>
        VoiceSession FindSession(string sessionHandle, bool make)
        {
            if (sessions.ContainsKey(sessionHandle))
                return sessions[sessionHandle];

            if (!make) return null;

            // Create a new session and add it to the sessions list.
            VoiceSession s = new VoiceSession(this, sessionHandle);

            // Turn on position updating for spatial sessions
            // (For now, only spatial sessions are supported)
            if (s.IsSpatial)
                PosUpdating(true);

            // Register the session by its handle
            sessions.Add(sessionHandle, s);
            return s;
        }
Esempio n. 4
0
        void gateway_OnSessionCreate(object sender, EventArgs e)
        {
            if (queriedDevices == false)
            {
                queriedDevices = true;
                Logger.Log("Voice session started, asking for device info", Helpers.LogLevel.Debug);
                gateway.AuxGetCaptureDevices();
                gateway.AuxGetRenderDevices();
            }

            VoiceSession s = sender as VoiceSession;

            BeginInvoke(new MethodInvoker(delegate()
             {
                 // There could theoretically be more than one session active
                 // at a time, but the current implementation in SL seems to be limited to one.
                 session = s;
                 session.OnParticipantAdded += new EventHandler(session_OnParticipantAdded);
                 session.OnParticipantRemoved += new EventHandler(session_OnParticipantRemoved);
                 session.OnParticipantUpdate += new EventHandler(session_OnParticipantUpdate);
                 participants.Clear();

                 // Default Mic off and Spkr on
                 gateway.MicMute = true;
                 gateway.SpkrMute = false;
                 gateway.SpkrLevel = 64;
                 gateway.MicLevel = 64;

                 SetProgress(VoiceGateway.ConnectionState.SessionRunning);
             }));
        }
Esempio n. 5
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;
            }
        }
Esempio n. 6
0
        void connector_OnSessionAddedEvent(object sender, SessionAddedEventArgs e)
        {
            sessionHandle = e.SessionHandle;

            // Create our session context.
            VoiceSession s = FindSession(sessionHandle, true);
            s.RegionName = regionName;

            spatialSession = s;

            // Tell any user-facing code.
            if (OnSessionCreate != null)
                OnSessionCreate(s, null);

            Logger.Log("Added voice session in " + regionName, Helpers.LogLevel.Info);
        }
Esempio n. 7
0
        /// <summary>
        /// Close a voice session
        /// </summary>
        /// <param name="sessionHandle"></param>
        internal void CloseSession(string sessionHandle)
        {
            if (!sessions.ContainsKey(sessionHandle))
                return;

            PosUpdating(false);
            ReportConnectionState(ConnectionState.AccountLogin);

            // Clean up spatial pointers.
            VoiceSession s = sessions[sessionHandle];
            if (s.IsSpatial)
            {
                spatialSession = null;
                currentParcelCap = null;
            }

            // Remove this session from the master session list
            sessions.Remove(sessionHandle);

            // Let any user-facing code clean up.
            if (OnSessionRemove != null)
                OnSessionRemove(s, null);

            // Tell SLVoice to clean it up as well.
            SessionTerminate(sessionHandle);
        }
 public VoiceParticipant(string puri, VoiceSession s)
 {
     id = IDFromName(puri);
     Sip = puri;
     session = s;
 }
Esempio n. 9
0
 void OnSessionCreate(object sender, EventArgs e)
 {
     session = sender as VoiceSession;
     control.talker.Say("Voice started in " + session.RegionName);
     //            session.OnParticipantAdded += new EventHandler(session_OnParticipantAdded);
 }