esl-client-netty4 is a Java-based Event Socket Library for the FreeSWITCH project.
This project is a fork of the unmaintained, original project at:
https://freeswitch.org/stash/projects/FS/repos/freeswitch-contrib/browse/dvarnes/java/esl-client
Status: In Progress...
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.
- 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
If you download and install the jar(s) manually, you must also supply the following jars on your Java classpath
- netty-4.1.50.Final.jar for async socket comms
- slf4j-api-1.7.30.jar for logging
- guava:29.0-jre Google core libraries for Java
- An slf4j implementation, use slf4j-nop.jar if no logging required.
package com.ecovate.freeswitch.lb;
import com.google.common.base.Throwables;
import org.freeswitch.esl.client.inbound.Client;
import org.freeswitch.esl.client.inbound.IEslEventListener;
import org.freeswitch.esl.client.internal.IModEslApi.EventFormat;
import org.freeswitch.esl.client.outbound.Context;
import org.freeswitch.esl.client.outbound.IClientHandler;
import org.freeswitch.esl.client.outbound.IClientHandlerFactory;
import org.freeswitch.esl.client.outbound.SocketClient;
import org.freeswitch.esl.client.transport.event.EslEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.InetSocketAddress;
public class FreeSwitchEventListener {
private static Logger logger = LoggerFactory.getLogger(FreeSwitchEventListener.class);
public static void main(String[] args) {
try {
final Client inboudClient = new Client();
inboudClient.connect(new InetSocketAddress("localhost", 8021), "ClueCon", 10);
inboudClient.addEventListener(new IEslEventListener() {
@Override
public void onEslEvent(EslEvent eslEvent) {
}
});
inboudClient.setEventSubscriptions(EventFormat.PLAIN, "all");
final SocketClient outboundServer = new SocketClient(
new InetSocketAddress("localhost", 8084),
new IClientHandlerFactory() {
@Override
public IClientHandler createClientHandler() {
return new IClientHandler() {
@Override
public void handleEslEvent(Context context, EslEvent eslEvent) {
}
@Override
public void onConnect(Context context, EslEvent eslEvent) {
}
};
}
});
} catch (Throwable t) {
Throwables.propagate(t);
}
}
}
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
- Maven
<dependency>
<groupId>org.freeswitch.esl.client</groupId>
<artifactId>esl-client-netty4</artifactId>
<version>0.9.2</version>
<type>pom</type>
</dependency>
- Gradle
implementation 'org.freeswitch.esl.client:esl-client-netty4:0.9.2'
- Ivy
<dependency org='org.freeswitch.esl.client' name='esl-client-netty4' rev='0.9.2'>
<artifact name='esl-client-netty4' ext='pom' ></artifact>
</dependency>
- Dan Cunningham
- Dave Rusek
- David Varnes (original author)
- Tobias Bieniek
esl-client-netty4 is licensed under the Apache License, version 2.