Search in sources :

Example 1 with OriginateAction

use of org.asteriskjava.manager.action.OriginateAction in project opennms by OpenNMS.

the class AsteriskOriginator method originateCall.

/**
 * Originates a call based on properties set on this bean.
 *
 * @throws org.opennms.netmgt.asterisk.utils.AsteriskOriginatorException if any.
 */
public void originateCall() throws AsteriskOriginatorException {
    OriginateAction originateAction = buildOriginateAction();
    LOG.info("Logging in Asterisk manager connection");
    try {
        m_managerConnection.login();
    } catch (final IllegalStateException ise) {
        throw new AsteriskOriginatorException("Illegal state logging in Asterisk manager connection", ise);
    } catch (final IOException ioe) {
        throw new AsteriskOriginatorException("I/O exception logging in Asterisk manager connection", ioe);
    } catch (final AuthenticationFailedException afe) {
        throw new AsteriskOriginatorException("Authentication failure logging in Asterisk manager connection", afe);
    } catch (final TimeoutException toe) {
        throw new AsteriskOriginatorException("Timed out logging in Asterisk manager connection", toe);
    }
    LOG.info("Successfully logged in Asterisk manager connection");
    LOG.info("Originating a call to extension {}", m_legAExtension);
    LOG.debug(createCallLogMsg());
    LOG.debug("Originate action:\n\n{}", originateAction.toString());
    ManagerResponse managerResponse = null;
    try {
        managerResponse = m_managerConnection.sendAction(originateAction);
    } catch (final IllegalArgumentException iae) {
        m_managerConnection.logoff();
        throw new AsteriskOriginatorException("Illegal argument sending originate action", iae);
    } catch (final IllegalStateException ise) {
        m_managerConnection.logoff();
        throw new AsteriskOriginatorException("Illegal state sending originate action", ise);
    } catch (final IOException ioe) {
        m_managerConnection.logoff();
        throw new AsteriskOriginatorException("I/O exception sending originate action", ioe);
    } catch (final TimeoutException toe) {
        m_managerConnection.logoff();
        throw new AsteriskOriginatorException("Timed out sending originate action", toe);
    }
    LOG.info("Asterisk manager responded: {}", managerResponse.getResponse());
    LOG.info("Asterisk manager message: {}", managerResponse.getMessage());
    if (managerResponse.getResponse().toLowerCase().startsWith("error")) {
        m_managerConnection.logoff();
        throw new AsteriskOriginatorException("Got error response sending originate event. Response: " + managerResponse.getResponse() + "; Message: " + managerResponse.getMessage());
    }
    LOG.info("Logging off Asterisk manager connection");
    m_managerConnection.logoff();
    LOG.info("Successfully logged off Asterisk manager connection");
}
Also used : ManagerResponse(org.asteriskjava.manager.response.ManagerResponse) AuthenticationFailedException(org.asteriskjava.manager.AuthenticationFailedException) IOException(java.io.IOException) OriginateAction(org.asteriskjava.manager.action.OriginateAction) TimeoutException(org.asteriskjava.manager.TimeoutException)

Example 2 with OriginateAction

use of org.asteriskjava.manager.action.OriginateAction in project openmeetings by apache.

the class SipDao method joinToConfCall.

/**
 * Perform call to specified phone number and join to conference
 *
 * @param number
 *            number to call
 * @param r
 *            room to be connected to the call
 */
public void joinToConfCall(String number, Room r) {
    String sipNumber = (r != null && r.getConfno() != null) ? r.getConfno() : null;
    if (sipNumber == null) {
        log.warn("Failed to get SIP number for room: {}", r);
        return;
    }
    OriginateAction oa = new OriginateAction();
    oa.setChannel(String.format("Local/%s@rooms-originate", sipNumber));
    oa.setContext("rooms-out");
    oa.setExten(number);
    oa.setPriority(1);
    oa.setTimeout(timeout);
    exec(oa);
}
Also used : OriginateAction(org.asteriskjava.manager.action.OriginateAction)

Example 3 with OriginateAction

use of org.asteriskjava.manager.action.OriginateAction in project opennms by OpenNMS.

the class AsteriskOriginator method buildOriginateAction.

/**
 * Build a complete OriginateAction ready for dispatching.
 *
 * @return completed OriginateAction, ready to be passed to ManagerConnection.sendAction
 * @throws org.opennms.netmgt.asterisk.utils.AsteriskOriginatorException if any of the underlying operations fail
 */
public OriginateAction buildOriginateAction() throws AsteriskOriginatorException {
    final OriginateAction action = new OriginateAction();
    action.setCallerId(m_callerId);
    setLegAChannel(expandPattern(m_legAChannelPattern));
    action.setChannel(getLegAChannel());
    action.setTimeout(m_dialTimeout);
    action.setCallerId(m_callerId);
    if (m_legBIsApp) {
        action.setApplication(expandPattern(m_legBAppPattern));
        action.setData(expandPattern(m_legBAppDataPattern));
    } else {
        action.setContext(m_legBContext);
        action.setExten(m_legBExtension);
        action.setPriority(m_legBPriority);
    }
    action.setVariables(m_channelVars);
    return action;
}
Also used : OriginateAction(org.asteriskjava.manager.action.OriginateAction)

Aggregations

OriginateAction (org.asteriskjava.manager.action.OriginateAction)3 IOException (java.io.IOException)1 AuthenticationFailedException (org.asteriskjava.manager.AuthenticationFailedException)1 TimeoutException (org.asteriskjava.manager.TimeoutException)1 ManagerResponse (org.asteriskjava.manager.response.ManagerResponse)1