Search in sources :

Example 6 with EslMessage

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

the class Client method deleteEventFilter.

/**
     * Delete an event filter from the current set of event filters on this connection.  See  
     * {@link Client.addEventFilter}   
     * 
     * @param eventHeader   to remove
     * @param valueToFilter to remove
     * @return a {@link CommandResponse} with the server's response.
     */
public CommandResponse deleteEventFilter(String eventHeader, String valueToFilter) {
    checkConnected();
    InboundClientHandler handler = (InboundClientHandler) channel.getPipeline().getLast();
    StringBuilder sb = new StringBuilder();
    if (eventHeader != null && !eventHeader.isEmpty()) {
        sb.append("filter delete ");
        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 EslMessage

use of org.freeswitch.esl.client.transport.message.EslMessage in project openhab1-addons by openhab.

the class FreeswitchBinding method initMessageItems.

/**
     * query freeswitch for the message count for VM accounts. This should
     * be done every time we connect to the system.
     */
private void initMessageItems() {
    mwiCache.clear();
    for (FreeswitchBindingProvider provider : providers) {
        for (String itemName : provider.getItemNames()) {
            FreeswitchBindingConfig config = provider.getFreeswitchBindingConfig(itemName);
            if (config.getType() == FreeswitchBindingType.MESSAGE_WAITING) {
                String account = config.getArgument();
                if (!mwiCache.containsKey(account) && clientValid()) {
                    EslMessage msg = inboudClient.sendSyncApiCommand("vm_boxcount", account);
                    if (msg.getBodyLines().size() == 1) {
                        try {
                            int messages = Integer.parseInt(msg.getBodyLines().get(0));
                            mwiCache.put(account, new MWIModel(messages > 0, messages));
                            updateMessageWaitingItem(config);
                        } catch (Exception e) {
                            logger.error("Could not parse messages", e);
                        }
                    }
                }
            }
        }
    }
}
Also used : EslMessage(org.freeswitch.esl.client.transport.message.EslMessage) FreeswitchBindingProvider(org.openhab.binding.freeswitch.FreeswitchBindingProvider) ConfigurationException(org.osgi.service.cm.ConfigurationException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 8 with EslMessage

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

the class Client method sendMessage.

/**
     * Send a {@link SendMsg} command to FreeSWITCH.  This client requires that the {@link SendMsg}
     * has a call UUID parameter.
     *  
     * @param sendMsg a {@link SendMsg} with call UUID
     * @return a {@link CommandResponse} with the server's response.
     */
public CommandResponse sendMessage(SendMsg sendMsg) {
    checkConnected();
    InboundClientHandler handler = (InboundClientHandler) channel.getPipeline().getLast();
    EslMessage response = handler.sendSyncMultiLineCommand(channel, sendMsg.getMsgLines());
    return new CommandResponse(sendMsg.toString(), response);
}
Also used : EslMessage(org.freeswitch.esl.client.transport.message.EslMessage) CommandResponse(org.freeswitch.esl.client.transport.CommandResponse)

Example 9 with EslMessage

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

the class Client method cancelEventSubscriptions.

/**
     * Cancel any existing event subscription.
     * 
     * @return a {@link CommandResponse} with the server's response.
     */
public CommandResponse cancelEventSubscriptions() {
    checkConnected();
    InboundClientHandler handler = (InboundClientHandler) channel.getPipeline().getLast();
    EslMessage response = handler.sendSyncSingleLineCommand(channel, "noevents");
    return new CommandResponse("noevents", response);
}
Also used : EslMessage(org.freeswitch.esl.client.transport.message.EslMessage) CommandResponse(org.freeswitch.esl.client.transport.CommandResponse)

Example 10 with EslMessage

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

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