Exemplo n.º 1
0
        public Conference( AriClient c, Guid id, string name)
        {
            _client = c;
            Id = id;
            ConferenceName = name;
            State = ConferenceState.Destroyed;

            c.OnChannelDtmfReceivedEvent += c_OnChannelDtmfReceivedEvent;
            c.OnBridgeCreatedEvent += c_OnBridgeCreatedEvent;
            c.OnChannelEnteredBridgeEvent += c_OnChannelEnteredBridgeEvent;
            c.OnBridgeDestroyedEvent += c_OnBridgeDestroyedEvent;
            c.OnChannelLeftBridgeEvent += c_OnChannelLeftBridgeEvent;
            c.OnRecordingFinishedEvent += c_OnRecordingFinishedEvent;

            // Added support for talk detection
            c.OnChannelTalkingStartedEvent += c_OnChannelTalkingStartedEvent;
            c.OnChannelTalkingFinishedEvent += c_OnChannelTalkingFinishedEvent;

            Debug.Print("Added Conference {0}", ConferenceName);
        }
Exemplo n.º 2
0
        public void DestroyConference()
        {
            State = ConferenceState.Destroying;

            ConferenceUsers.ForEach(x => RemoveUser(x.Channel.Id));
            if (Confbridge != null)
                _client.Bridges.Destroy(Confbridge.Id);
            Confbridge = null;

            State = ConferenceState.Destroyed;
        }
Exemplo n.º 3
0
        public bool StartConference()
        {
            // TODO: fix this, .Connected returning false all the time
            //if (!client.Connected)
            //    return false;

            // Create the conference bridge
            Debug.Print("Requesting new bridge {0} for {1}", Id, ConferenceName);
            Bridge bridge = _client.Bridges.Create("mixing", Id.ToString(), ConferenceName);

            if (bridge == null)
            {
                return false;
            }


            Debug.Print("Subscribing to events on bridge {0} for {1}", Id, ConferenceName);
            _client.Applications.Subscribe(AppConfig.AppName, "bridge:" + bridge.Id);

            // Start MOH on conf bridge
            _client.Bridges.StartMoh(bridge.Id, "default");

            // Default state is ReadyWaiting until MOH is turned off
            State = ConferenceState.ReadyWaiting;
            Confbridge = bridge;

            // Conference ready to accept calls
            State = ConferenceState.Ready;

            return true;
        }
Exemplo n.º 4
0
        private void c_OnBridgeCreatedEvent(object sender, BridgeCreatedEvent e)
        {
            // Never gets fired!
            if (e.Bridge.Id != Id.ToString()) return;

            State = ConferenceState.Ready;
            Debug.Print("Created bridge {0} for {1}", Id, ConferenceName);
        }
Exemplo n.º 5
0
        private void c_OnChannelEnteredBridgeEvent(object sender, ChannelEnteredBridgeEvent e)
        {
            ConferenceUser confUser = ConferenceUsers.SingleOrDefault(x => x.Channel.Id == e.Channel.Id);
            if (confUser == null) return;

            confUser.State = ConferenceUserState.InConf;

            if (ConferenceUsers.Count(x => x.State == ConferenceUserState.InConf) > 1) // are we the only ones here
            {
                // stop moh
                _client.Bridges.StopMoh(Confbridge.Id);

                // change state
                State = ConferenceState.Ready;

                // announce new user
                _client.Bridges.Play(Confbridge.Id, "recording:" + confUser.CurrentRecodingId, "en", 0, 0, Guid.NewGuid().ToString());
                _client.Bridges.Play(Confbridge.Id, "sound:conf-hasjoin", "en", 0, 0, Guid.NewGuid().ToString());
            }
            else
            {
                // only caller in conf
                _client.Channels.Play(e.Channel.Id, "sound:conf-onlyperson", "en", 0, 0, Guid.NewGuid().ToString());
            }
        }
Exemplo n.º 6
0
 private void c_OnBridgeDestroyedEvent(object sender, BridgeDestroyedEvent e)
 {
     if (e.Bridge.Id == Id.ToString())
         State = ConferenceState.Destroyed;
 }