[Freeswitch-users] event socket

Hector Geraldino Hector.Geraldino at ip-soft.net
Tue Oct 25 19:13:08 MSD 2011


What Type is returned by the .Execute() method call?

Maybe you should create a new variable and assign the returned value to it, so you can inspect the result of the method call, something like:
                EslMessage response = eslConnection.Execute("answer", null, CallID);
String isOk = response.getHeaderValue("Reply-Text");
so you can inspect the response returned by FreeSwitch.

BTW, this is mostly Java code so I'm not sure that these Types/properties are available on the C# assemblies.

And finally, try to perform this operation after receiving the CHANNEL_DATA event instead of CHANNEL_STATE.


From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Nuwan Wijerathne
Sent: Tuesday, October 25, 2011 10:54 AM
To: FreeSWITCH Users Help
Subject: Re: [Freeswitch-users] event socket

Hi,

CallID is a variable I defined. I'm assigning the call Unique-ID to this variable as follows,

                string CallID = eventHandle.GetHeader("Unique-ID");
My full code is at the bottom of this email,

Thank you,

Nuwan Wijerathne

Software Engineering Department

Unify Business Solutions Ltd
Ambassador House, 5 Midland Way, Barlborough, Chesterfield, S43 4XA
Mobile: 07834 001304  | Tel: 08458717788 | Fax: 08458717799
Website: www.unifybusiness.co.uk

From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Hynek Cihlar
Sent: 25 October 2011 15:43
To: FreeSWITCH Users Help
Subject: Re: [Freeswitch-users] event socket

You want the Unique-ID variable of the incoming message, not CallID.

Hynek

On Tue, Oct 25, 2011 at 4:36 PM, Nuwan Wijerathne <NuwanW at unifybusiness.co.uk<mailto:NuwanW at unifybusiness.co.uk>> wrote:
            Sorry still no progress, code as follows

               if (eventHandle.getType() == "CHANNEL_STATE" && eventHandle.GetHeader("Answer-State") == "ringing")
                {
                    eslConnection.Execute("answer", null, CallID);
                }
Thank you,

From: freeswitch-users-bounces at lists.freeswitch.org<mailto:freeswitch-users-bounces at lists.freeswitch.org> [mailto:freeswitch-users-bounces at lists.freeswitch.org<mailto:freeswitch-users-bounces at lists.freeswitch.org>] On Behalf Of Hynek Cihlar
Sent: 25 October 2011 15:23

To: FreeSWITCH Users Help
Subject: Re: [Freeswitch-users] event socket

You also have to provide the UUID of the channel, so freeswitch knows which one to answer.

Sent from my mobile device

On Oct 25, 2011, at 16:19, Nuwan Wijerathne <NuwanW at unifybusiness.co.uk<mailto:NuwanW at unifybusiness.co.uk>> wrote:
I made the changes below, still no progress,

                 if (eventHandle.getType() == "CHANNEL_STATE" && eventHandle.GetHeader("Answer-State") == "ringing")
                {
                    eslConnection.Execute("answer", null, null);
                }

Thank you,

Nuwan Wijerathne

Software Engineering Department

Unify Business Solutions Ltd
Ambassador House, 5 Midland Way, Barlborough, Chesterfield, S43 4XA
Mobile: 07834 001304  | Tel: 08458717788 | Fax: 08458717799
Website: www.unifybusiness.co.uk<http://www.unifybusiness.co.uk>

From: freeswitch-users-bounces at lists.freeswitch.org<mailto:freeswitch-users-bounces at lists.freeswitch.org> [mailto:freeswitch-users-bounces at lists.freeswitch.org<mailto:freeswitch-users-bounces at lists.freeswitch.org>] On Behalf Of Hynek Cihlar
Sent: 25 October 2011 14:54
To: FreeSWITCH Users Help
Subject: Re: [Freeswitch-users] event socket

Answer on event CHANNEL_CALLSTATE and channel call state RINGING.

Hynek
On Tue, Oct 25, 2011 at 3:49 PM, Nuwan Wijerathne <NuwanW at unifybusiness.co.uk<mailto:NuwanW at unifybusiness.co.uk>> wrote:
Hi,

Thanks for the reply. Yes my application is listening on the port and I'm receiving events. However when I try to execute "answer" application it's not working. I'm trying to execute "answer" application when I receive "CHANNEL_CREATE" event on inbound calls. Please see code below. Could you Please advise

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;

namespace ESLTest
{
    public class Test
    {
        private Dictionary<string, Call> CallsTable;

        private Thread ThreadReader;

        private ESLconnection eslConnection;

        private const int CONNECTED = 1;

        private const string server = "localhost";
        private const string port = "8021";
        private const string password = "ClueCon";


        public Test()
        {
            CallsTable = new Dictionary<string, Call>();
            Connect();
        }


        private void Connect()
        {
            eslConnection = new ESLconnection(server, port, password);

            if (eslConnection.Connected().Equals( CONNECTED))
            {
                Console.WriteLine("Conneected to FreeSwitch");

                ThreadReader = new Thread(new ThreadStart(Read));
                ThreadReader.Start();
            }
            else
            {
                Console.WriteLine("Conneection Failure");
            }
        }



        private void Read()
        {
            ESLevent eventHandle = eslConnection.SendRecv("event plain ALL");

            if (eventHandle == null)
            {
                Console.WriteLine("Error subscribing to all events");
                return;
            }
            else
           {
                Console.WriteLine("Subscribed to all events");
            }

            while (true)
            {
                eventHandle = eslConnection.RecvEvent();

                string CallID = eventHandle.GetHeader("Unique-ID");

                if (eventHandle.getType() == "CHANNEL_CREATE")
                {
                    //Inbound call
                    if (eventHandle.GetHeader("Call-Direction") == "inbound")
                    {
                        CallsTable.Add(CallID, new Call(CallID));
                        eslConnection.Execute("answer", null, null);
                        Console.WriteLine(string.Format("{0} : Inbound CallID : {1}", eventHandle.getType(), CallID));
                    }
                }
           }
    }
}

Dialplan entry as follows,

                <extension name="intercept">
                     <condition field="destination_number" expression="^9$">
                           <action application="socket" data="127.0.0.1:8021<http://127.0.0.1:8021> async full"/>
                    </condition>
                </extension>

Thank you,

From: freeswitch-users-bounces at lists.freeswitch.org<mailto:freeswitch-users-bounces at lists.freeswitch.org> [mailto:freeswitch-users-bounces at lists.freeswitch.org<mailto:freeswitch-users-bounces at lists.freeswitch.org>] On Behalf Of Michael Collins
Sent: 24 October 2011 18:14
To: FreeSWITCH Users Help
Subject: Re: [Freeswitch-users] event socket

Please confirm: are you sending the call to the "socket" application in your dialplan? If so, then your ESL app needs to be listening on the TCP port specified. See the examples here: http://wiki.freeswitch.org/wiki/Event_Socket_Outbound#Examples

-MC
On Mon, Oct 24, 2011 at 8:50 AM, Nuwan Wijerathne <NuwanW at unifybusiness.co.uk<mailto:NuwanW at unifybusiness.co.uk>> wrote:
Hi,

I'm trying to build an IVR application around freeswtich. I'm using freeswitch event socket in C#. I'm intercepting inbound calls in the dial plan and sending them to my application via outbound socket. Could someone please explain how to execute "answer" application through event socket.

Eg - I'm sending the command as below and it's not working.

ESLConnection eslConnection = new ESLConnection(server, port, password)
ESLEvent eventHandle = eslConnection.SendRecv("event plain ALL");

eventHandle = eslConnection.RecvEvent();
string uniqueCallID = evenHandle.GetHeader("Unique-ID");

eslConnection.Execute("answer", string.Empty, UniqueCallID);


I believe I'm doing something wrong as I can't find required information. Could someone please let me know where to find more information about freeswitch event socket in .Net. (Google not giving me required information)

Thank you,



FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org<mailto:FreeSWITCH-users at lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org



FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org<mailto:FreeSWITCH-users at lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org


FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org<mailto:FreeSWITCH-users at lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org


FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org<mailto:FreeSWITCH-users at lists.freeswitch.org>
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20111025/238b864a/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list