static void Main(string[] args) { try { // Create a message actionClient to receive events on ActionClient = new AriClient(new StasisEndpoint("192.168.3.16", 8088, "username", "test"), AppName); ActionClient.OnStasisStartEvent += c_OnStasisStartEvent; ActionClient.OnStasisEndEvent += c_OnStasisEndEvent; ActionClient.Connect(); // Create simple bridge SimpleBridge = ActionClient.Bridges.Create("mixing", Guid.NewGuid().ToString(), AppName); // subscribe to bridge events ActionClient.Applications.Subscribe(AppName, "bridge:" + SimpleBridge.Id); // start MOH on bridge ActionClient.Bridges.StartMoh(SimpleBridge.Id, "default"); var done = false; while (!done) { var lastKey = Console.ReadKey(); switch(lastKey.KeyChar.ToString()) { case "*": done = true; break; case "1": ActionClient.Bridges.StopMoh(SimpleBridge.Id); break; case "2": ActionClient.Bridges.StartMoh(SimpleBridge.Id, "default"); break; case "3": // Mute all channels on bridge var bridgeMute = ActionClient.Bridges.Get(SimpleBridge.Id); foreach (var chan in bridgeMute.Channels) ActionClient.Channels.Mute(chan, "in"); break; case "4": // Unmute all channels on bridge var bridgeUnmute = ActionClient.Bridges.Get(SimpleBridge.Id); foreach (var chan in bridgeUnmute.Channels) ActionClient.Channels.Unmute(chan, "in"); break; } } ActionClient.Bridges.Destroy(SimpleBridge.Id); ActionClient.Disconnect(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Console.ReadKey(); } }
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; }
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; }