use of org.freeswitch.esl.client.transport.event.EslEvent in project bigbluebutton by bigbluebutton.
the class AbstractEslClientHandler method messageReceived.
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
if (e.getMessage() instanceof EslMessage) {
EslMessage message = (EslMessage) e.getMessage();
String contentType = message.getContentType();
if (contentType.equals(Value.TEXT_EVENT_PLAIN) || contentType.equals(Value.TEXT_EVENT_XML)) {
// transform into an event
EslEvent eslEvent = new EslEvent(message);
handleEslEvent(ctx, eslEvent);
} else {
handleEslMessage(ctx, (EslMessage) e.getMessage());
}
} else {
throw new IllegalStateException("Unexpected message type: " + e.getMessage().getClass());
}
}
use of org.freeswitch.esl.client.transport.event.EslEvent in project bigbluebutton by bigbluebutton.
the class AbstractOutboundClientHandler method channelConnected.
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
// Have received a connection from FreeSWITCH server, send connect response
log.debug("Received new connection from server, sending connect message");
EslMessage response = sendSyncSingleLineCommand(ctx.getChannel(), "connect");
// The message decoder for outbound, treats most of this incoming message as an 'event' in
// message body, so it parse now
EslEvent channelDataEvent = new EslEvent(response, true);
// Let implementing sub classes choose what to do next
handleConnectResponse(ctx, channelDataEvent);
}
use of org.freeswitch.esl.client.transport.event.EslEvent in project bigbluebutton by bigbluebutton.
the class ClientTest method do_connect.
@Test
public void do_connect() throws InterruptedException {
Client client = new Client();
client.addEventListener(new IEslEventListener() {
public void eventReceived(EslEvent event) {
log.info("Event received [{}]", event);
}
public void backgroundJobResultReceived(EslEvent event) {
log.info("Background job result received [{}]", event);
}
public void conferenceEventJoin(String uniqueId, String confName, int confSize, EslEvent event) {
log.info("Event received [{}]", event);
}
public void conferenceEventLeave(String uniqueId, String confName, int confSize, EslEvent event) {
log.info("Event received [{}]", event);
}
public void conferenceEventMute(String uniqueId, String confName, int confSize, EslEvent event) {
log.info("Event received [{}]", event);
}
public void conferenceEventUnMute(String uniqueId, String confName, int confSize, EslEvent event) {
log.info("Event received [{}]", event);
}
public void conferenceEventAction(String uniqueId, String confName, int confSize, String action, EslEvent event) {
log.info("Event received [{}]", event);
}
public void conferenceEventTransfer(String uniqueId, String confName, int confSize, EslEvent event) {
log.info("Event received [{}]", event);
}
public void conferenceEventThreadRun(String uniqueId, String confName, int confSize, EslEvent event) {
log.info("Event received [{}]", event);
}
public void conferenceEventPlayFile(String uniqueId, String confName, int confSize, EslEvent event) {
log.info("Event received [{}]", event);
}
public void exceptionCaught(ExceptionEvent e) {
log.info("exception received [{}]", e);
}
});
log.info("Client connecting ..");
try {
client.connect(host, port, password, 2);
} catch (InboundConnectionFailure e) {
log.error("Connect failed", e);
return;
}
log.info("Client connected ..");
// client.setEventSubscriptions( "plain", "heartbeat CHANNEL_CREATE CHANNEL_DESTROY BACKGROUND_JOB" );
client.setEventSubscriptions("plain", "all");
client.addEventFilter("Event-Name", "heartbeat");
client.cancelEventSubscriptions();
client.setEventSubscriptions("plain", "all");
client.addEventFilter("Event-Name", "heartbeat");
client.addEventFilter("Event-Name", "channel_create");
client.addEventFilter("Event-Name", "background_job");
client.sendSyncApiCommand("echo", "Foo foo bar");
// client.sendSyncCommand( "originate", "sofia/internal/101@192.168.100.201! sofia/internal/102@192.168.100.201!" );
// client.sendSyncApiCommand( "sofia status", "" );
String jobId = client.sendAsyncApiCommand("status", "");
log.info("Job id [{}] for [status]", jobId);
client.sendSyncApiCommand("version", "");
// client.sendAsyncApiCommand( "status", "" );
// client.sendSyncApiCommand( "sofia status", "" );
// client.sendAsyncApiCommand( "status", "" );
EslMessage response = client.sendSyncApiCommand("sofia status", "");
log.info("sofia status = [{}]", response.getBodyLines().get(3));
// wait to see the heartbeat events arrive
Thread.sleep(25000);
client.close();
}
Aggregations