Search in sources :

Example 6 with CommandResponse

use of org.freeswitch.esl.client.transport.CommandResponse in project bigbluebutton by bigbluebutton.

the class Client method addEventFilter.

/**
     * Add an event filter to the current set of event filters on this connection. Any of the event headers
     * can be used as a filter.
     * </p>
     * Note that event filters follow 'filter-in' semantics. That is, when a filter is applied
     * only the filtered values will be received. Multiple filters can be added to the current
     * connection.
     * </p>
     * Example filters:
     * <pre>
     *    eventHeader        valueToFilter
     *    ----------------------------------
     *    Event-Name         CHANNEL_EXECUTE
     *    Channel-State      CS_NEW
     * </pre>
     * 
     * @param eventHeader to filter on
     * @param valueToFilter the value to match
     * @return a {@link CommandResponse} with the server's response.
     */
public CommandResponse addEventFilter(String eventHeader, String valueToFilter) {
    checkConnected();
    InboundClientHandler handler = (InboundClientHandler) channel.getPipeline().getLast();
    StringBuilder sb = new StringBuilder();
    if (eventHeader != null && !eventHeader.isEmpty()) {
        sb.append("filter ");
        sb.append(eventHeader);
    }
    if (valueToFilter != null && !valueToFilter.isEmpty()) {
        sb.append(' ');
        sb.append(valueToFilter);
    }
    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 7 with CommandResponse

use of org.freeswitch.esl.client.transport.CommandResponse 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 8 with CommandResponse

use of org.freeswitch.esl.client.transport.CommandResponse 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 9 with CommandResponse

use of org.freeswitch.esl.client.transport.CommandResponse 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)

Aggregations

CommandResponse (org.freeswitch.esl.client.transport.CommandResponse)9 EslMessage (org.freeswitch.esl.client.transport.message.EslMessage)9