예제 #1
0
        /// <summary>
        /// Connects the current caller to a Client
        /// </summary>
        /// <param name="client">The Client to dial</param>
        /// <returns></returns>
		public TwilioResponse Dial(Client client)
		{
			BeginDial();
			Add(client);
			return EndDial();
		}
예제 #2
0
        /// <summary>
        /// Connects the current caller to a Client
        /// </summary>
        /// <param name="client">The Client to dial</param>
        /// <param name="dialAttributes"></param>
        /// <returns></returns>
        public TwilioResponse Dial(Client client, object dialAttributes)
		{
			BeginDial(dialAttributes);
			Add(client);
			return EndDial();
		}
        private TwilioResponse AddToResponse(TwilioResponse response, Agent agent)
        {
            var dialAttributes = new { method = "GET", action = GetEcho("dial"), timeout = agent.TimeOut, record = agent.Record ? "record-from-answer" : "do-not-record" };

            switch (agent.Answer)
            {
                case AnswerType.Number:
                    var number = new Number(agent.RedirectToNumber);
                    AddUrlAttr(number, GetEcho("client"));
                    response.Dial(number, dialAttributes);
                    break;
                case AnswerType.Client:
                    var client = new Client(agent.ClientID);
                    AddUrlAttr(client, GetEcho("client"));
                    response.Dial(client, dialAttributes);
                    break;
                case AnswerType.Sip:
                    response.Dial(new Sip(agent.ClientID), dialAttributes);
                    break;
            }

            return response;
        }