Search in sources :

Example 11 with EslMessage

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);
}
Also used : EslMessage(org.freeswitch.esl.client.transport.message.EslMessage) CommandResponse(org.freeswitch.esl.client.transport.CommandResponse)

Example 12 with EslMessage

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);
}
Also used : EslMessage(org.freeswitch.esl.client.transport.message.EslMessage) CommandResponse(org.freeswitch.esl.client.transport.CommandResponse)

Example 13 with EslMessage

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");
    }
}
Also used : EslMessage(org.freeswitch.esl.client.transport.message.EslMessage) CommandResponse(org.freeswitch.esl.client.transport.CommandResponse)

Example 14 with EslMessage

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());
    }
}
Also used : EslEvent(org.freeswitch.esl.client.transport.event.EslEvent) EslMessage(org.freeswitch.esl.client.transport.message.EslMessage)

Example 15 with EslMessage

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);
}
Also used : EslEvent(org.freeswitch.esl.client.transport.event.EslEvent) EslMessage(org.freeswitch.esl.client.transport.message.EslMessage)

Aggregations

EslMessage (org.freeswitch.esl.client.transport.message.EslMessage)21 CommandResponse (org.freeswitch.esl.client.transport.CommandResponse)9 Client (org.freeswitch.esl.client.inbound.Client)7 EslEvent (org.freeswitch.esl.client.transport.event.EslEvent)3 InboundConnectionFailure (org.freeswitch.esl.client.inbound.InboundConnectionFailure)2 Test (org.junit.Test)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 IEslEventListener (org.freeswitch.esl.client.IEslEventListener)1 SendMsg (org.freeswitch.esl.client.transport.SendMsg)1 Name (org.freeswitch.esl.client.transport.message.EslHeaders.Name)1 FreeswitchBindingProvider (org.openhab.binding.freeswitch.FreeswitchBindingProvider)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1