1, in the Linux environment has installed the FreeSWITCH, (not installed FreeSWITCH, please install the documentation)
2, enter the source code directory CD LIBS/ESL directory first install yum install Python-devel
L Install Python-devel First, execute yum install Python-devel
L Make Pymod
L Make Pymod-install
3, install the PIP tool to refer to a previous blog
4. Installing Swig tools, yum install Swig
5, after the installation of PIP, then installpython-ESL
执行 pip install python-ESL
Script:
Import ESL
Con = ESL. Eslconnection (' localhost ', ' 8021 ', ' Cluecon ') #通过ESL与freeswitch建立连接
If con.connected:
Con.events (' plain ', ' channel_create channel_answer channel_progress channel_progress_media CHANNEL_HANGUP ')
While 1:
E = Con.recvevent ()
Event_Name = E.getheader ("Event-name")
If event_name in ["Channel_create"]:
unique_id = E.getheader ("Unique-id")
Caller = E.getheader ("Caller-caller-id-number") #主叫 get the value in the message field according to things
callee = E.getheader ("Caller-destination-number") #被叫
Con.execute ("Ring_ready", "", unique_id)
Elif (Event_Name in [' server_disconnected ']):
Break
There are a number of functions can refer to LIBS/ESL examples and source code
Scripting Control FreeSWITCH Summary using the Python language