Ejemplo n.º 1
0
        public override void OnExternalAction(CallButlerScriptContext scriptContext, string command, string commandData)
        {
            if (command == "JoinConference")
            {
                int participants = 0;

                if (conferences.ContainsKey(commandData))
                {
                    participants = conferences[commandData].Count;
                }
                else
                {
                    conferences[commandData] = new List<CallButlerScriptContext>();
                }

                conferences[commandData].Add(scriptContext);

                scriptContext.SetScriptVariable("NumberInConference", participants.ToString());
            }
            else if (command == "PersonJoining")
            {
                if (conferences.ContainsKey(commandData))
                {
                    // Loop through the conferences and play our joining sound
                    List<CallButlerScriptContext> participants = conferences[commandData];

                    for (int index = 0; index < participants.Count; index++)
                    {
                        participants[index].SignalExternalScriptEvent("PersonJoining");
                    }
                }
            }
            else if (command == "LeaveConference")
            {
                if (conferences.ContainsKey(commandData))
                {
                    if (conferences[commandData].Contains(scriptContext))
                    {
                        conferences[commandData].Remove(scriptContext);

                        // Loop through the conferences and play our leaving sound
                        List<CallButlerScriptContext> participants = conferences[commandData];

                        for (int index = 0; index < participants.Count; index++)
                        {
                            participants[index].SignalExternalScriptEvent("PersonLeaving");
                        }
                    }

                    if (conferences[commandData].Count == 0)
                    {
                        conferences[commandData].Clear();

                        conferences.Remove(commandData);
                    }
                }
            }
        }