use of org.freeswitch.esl.client.transport.message.EslMessage in project bigbluebutton by bigbluebutton.
the class Client method setLoggingLevel.
/**
* Enable log output.
*
* @param level using the same values as in console.conf
* @return a {@link CommandResponse} with the server's response.
*/
public CommandResponse setLoggingLevel(String level) {
checkConnected();
InboundClientHandler handler = (InboundClientHandler) channel.getPipeline().getLast();
StringBuilder sb = new StringBuilder();
if (level != null && !level.isEmpty()) {
sb.append("log ");
sb.append(level);
}
EslMessage response = handler.sendSyncSingleLineCommand(channel, sb.toString());
return new CommandResponse(sb.toString(), response);
}
use of org.freeswitch.esl.client.transport.message.EslMessage in project bigbluebutton by bigbluebutton.
the class Client method setEventSubscriptions.
/**
* Set the current event subscription for this connection to the server. Examples of the events
* argument are:
* <pre>
* ALL
* CHANNEL_CREATE CHANNEL_DESTROY HEARTBEAT
* CUSTOM conference::maintenance
* CHANNEL_CREATE CHANNEL_DESTROY CUSTOM conference::maintenance sofia::register sofia::expire
* </pre>
* Subsequent calls to this method replaces any previous subscriptions that were set.
* </p>
* Note: current implementation can only process 'plain' events.
*
* @param format can be { plain | xml }
* @param events { all | space separated list of events }
* @return a {@link CommandResponse} with the server's response.
*/
public CommandResponse setEventSubscriptions(String format, String events) {
// temporary hack
if (!format.equals("plain")) {
throw new IllegalStateException("Only 'plain' event format is supported at present");
}
checkConnected();
InboundClientHandler handler = (InboundClientHandler) channel.getPipeline().getLast();
StringBuilder sb = new StringBuilder();
if (format != null && !format.isEmpty()) {
sb.append("event ");
sb.append(format);
}
if (events != null && !events.isEmpty()) {
sb.append(' ');
sb.append(events);
}
EslMessage response = handler.sendSyncSingleLineCommand(channel, sb.toString());
return new CommandResponse(sb.toString(), response);
}
use of org.freeswitch.esl.client.transport.message.EslMessage in project bigbluebutton by bigbluebutton.
the class InboundClientHandler method handleAuthRequest.
protected void handleAuthRequest(ChannelHandlerContext ctx) {
log.debug("Auth requested, sending [auth {}]", "*****");
EslMessage response = sendSyncSingleLineCommand(ctx.getChannel(), "auth " + password);
log.debug("Auth response [{}]", response);
if (response.getContentType().equals(Value.COMMAND_REPLY)) {
CommandResponse commandResponse = new CommandResponse("auth " + password, response);
listener.authResponseReceived(commandResponse);
} else {
log.error("Bad auth response message [{}]", response);
throw new IllegalStateException("Incorrect auth response");
}
}
use of org.freeswitch.esl.client.transport.message.EslMessage 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.message.EslMessage 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);
}
Aggregations