Freeswitch Javaeslclient 110817 1918 5028
Freeswitch Javaeslclient 110817 1918 5028
Freeswitch Javaeslclient 110817 1918 5028
About
This page documents the org.freeswitch.esl.client library maintained in the freeswitch-contrib git repository. See Java ESL page for overview of
other options for using Java with the FreeSWITCH Event Socket.
Click here to expand Table of Contents
Features
Licensed under Apache License version 2 http://www.apache.org/licenses/LICENSE-2.0
Runtime dependency on Netty (Apache License) and SLF4j (MIT License) libraries
No native library runtime dependencies
ESL Inbound and Outbound support, see Event Socket and Event Socket Outbound.
OSGi ready
Built using maven
org.freeswitch.esl.client-0.9.2.jar
org.freeswitch.esl.client-0.9.2-sources.jar
org.freeswitch.esl.client-0.9.2-javadoc.jar
Each of these artifacts is signed with GPG key 1024D/74B7C72A (david.varnes [at] gmail [dot] com), which allows you to verify that the binary
files you download are the same as those originally uploaded.
Download manually
https://oss.sonatype.org/content/repositories/releases/org/freeswitch/esl/client/org.freeswitch.esl.client/
This is the hosted repository maintained by Sonatype for OSS projects. The files are automatically synced from there to the maven central
repository
Assuming you are using a build tool that can resolve dependencies from the maven 2 central repository, add the following to your project pom.xml
<dependencies>
...
<dependency>
<groupId>org.freeswitch.esl.client</groupId>
<artifactId>org.freeswitch.esl.client</artifactId>
<version>0.9.2</version>
</dependency>
...
</dependencies>
Note: The netty dependency is not available from the maven 2 central repository. Either:
Runtime dependencies
If you download and install the jar(s) manually, you must also supply the following jars on your Java classpath
A Java build tool analogous in some ways to 'autotools' and 'make' for the main FreeSWITCH code, this library is built using the maven build tool.
Installing maven is beyond the scope of this page, just use the latest available from the link, and it is also packaged for some of the major Linux
distributions.
Maven will download the two compile dependencies (netty and slf4j-api) and the test dependency (logback) for you, as well as compile the java
classes, run unit tests and assemble the 'jar' archive file.
Must first install git. The code can be obtained from the freeswitch-contrib git repository. This command gets that repository (you get all the other
good stuff in freeswitch-contrib too).
$ cd freeswitch-contrib/dvarnes/java/esl-client
$ mvn install
If this is the first time you have run the maven tool, it will take some time as it downloads a seemingly endless set of jars from the central maven
repository. This will only happen the first time, subsequent builds will be much faster.
Note: some tests will try to connect to a running FreeSWITCH installation on the default port 8021 and password. See Configuration section of Ev
ent_Socket. These tests will not be run in a normal maven build, you will need to run them however you usually invoke junit test cases (IDE etc).
These tests try to connect to a host called 'freeswitch-test', so add an entry to your hosts file that points 'freeswitch-test' to a host that with a
listening ESL socket, can be localhost.
Usage
For general usage of the ESL, browse the wiki, some links below. Each of the different wiki pages for various language bindings and clients have
useful snippets and clues.
Chapter 9 of the FreeSWITCH Book also introduces events and the ESL.
This test assumes that it can connect to a FreeSWITCH with the default socket port and password at a host called 'freeswitch-test' in your hosts
file.
Note that the test source is not included in the packaged jar, it is available from the git repository.
org.freeswitch.esl.client.outbound.example.SimpleHangupOutboundHandler
with an example of how to run it in the Outbound 'unit' test (really an application example) in the the src/test/java source directory.
In order to make the test work, configure an extension in a running FreeSWITCH similar to
<extension>
<condition field="destination_number" expression="444">
<action application="socket" data="192.168.100.88:8084 async full"/>
</condition>
</extension>
where the IP address needs to be the address that the FreeSWITCH will connect to your running test. Then run the test, which gives you 45
seconds to make a call to extension 444 and watch the information logged to the console, before the call is hung up, and then the test will end
(thus closing the outbound socket client).
Note that the unit test source described above is not included in the packaged jar, it is available from the git repository.
Outbound application
org.freeswitch.esl.client.outbound.AbstractOutboundClientHandler
org.freeswitch.esl.client.outbound.AbstractOutboundPipelineFactory
org.freeswitch.esl.client.outbound.SocketClient
Issues
TODO - set up module under FreeSWITCH Jira
Feedback, questions, issues, patches are very welcome either directly to the email address below, or via the freeswitch-users mailing list. The
author is generally in IRC using nick 'dvarnes'.
Roadmap
As of 30 August 2010
You can donate to the author via paypal to david.varnes [at] gmail [dot] com
See Also
Event Socket
Event Socket Library
Event Socket Outbound
Debugging Event Socket Message
Event List