Package org.asteriskjava.manager.response

Examples of org.asteriskjava.manager.response.ManagerResponse


        }
    }

    public void pauseMonitoring() throws ManagerCommunicationException, NoSuchChannelException
    {
        ManagerResponse response;

        response = server.sendAction(new PauseMonitorAction(name));
        if (response instanceof ManagerError)
        {
            throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage());
        }
    }
View Full Code Here


        }
    }

    public void unpauseMonitoring() throws ManagerCommunicationException, NoSuchChannelException
    {
        ManagerResponse response;

        response = server.sendAction(new UnpauseMonitorAction(name));
        if (response instanceof ManagerError)
        {
            throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage());
        }
    }
View Full Code Here

    }

   
    public void pauseMixMonitor(MixMonitorDirection direction) throws ManagerCommunicationException, NoSuchChannelException
    {
        ManagerResponse response;
        response = server.sendAction(new PauseMixMonitorAction(this.name,1,direction.getStateName()));
        if (response instanceof ManagerError) {
            throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage());
        }
    }
View Full Code Here

    }

   
    public void unPauseMixMonitor(MixMonitorDirection direction) throws ManagerCommunicationException, NoSuchChannelException
    {
        ManagerResponse response;
        response = server.sendAction(new PauseMixMonitorAction(this.name,0,direction.getStateName()));       
        if (response instanceof ManagerError) {
            throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage());
        }
    }
View Full Code Here

    }

    public void sendCommand(AgiCommand command) throws AgiException
    {
        final AgiAction agiAction;
        final ManagerResponse response;

        agiAction = new AgiAction(channelName, command.buildCommand());

        try
        {
            response = connection.sendAction(agiAction);
        }
        catch (IOException e)
        {
            throw new AgiException("Unable to send AsyncAGI command to " + connection.getHostname() +
                    " for channel " + channelName, e);
        }
        catch (TimeoutException e)
        {
            throw new AgiException("Timeout while sending AsyncAGI command to " + connection.getHostname() +
                    " for channel " + channelName , e);
        }

        if (response instanceof ManagerError)
        {
            throw new AgiException("Unable to send AsyncAGI command to " + connection.getHostname() +
                    " for channel " + channelName + ": " + response.getMessage());
        }
    }
View Full Code Here

            {
                c.sendAction(new PingAction(), null);
            }
            else
            {
                final ManagerResponse response;

                response = c.sendAction(new PingAction(), timeout);
                logger.debug("Ping response '" + response + "' for " + c.toString());
            }
        }
View Full Code Here

     */
    protected synchronized void doLogin(long timeout, String eventMask) throws IOException, AuthenticationFailedException,
            TimeoutException
    {
        ChallengeAction challengeAction;
        ManagerResponse challengeResponse;
        String challenge;
        String key;
        LoginAction loginAction;
        ManagerResponse loginResponse;

        if (socket == null)
        {
            connect();
        }

        synchronized (protocolIdentifier)
        {
            if (protocolIdentifier.value == null)
            {
                try
                {
                    protocolIdentifier.wait(timeout);
                }
                catch (InterruptedException e) // NOPMD
                {
                    Thread.currentThread().interrupt();
                }
            }

            if (protocolIdentifier.value == null)
            {
                disconnect();
                if (reader != null && reader.getTerminationException() != null)
                {
                    throw reader.getTerminationException();
                }
                else
                {
                    throw new TimeoutException("Timeout waiting for protocol identifier");
                }
            }
        }

        challengeAction = new ChallengeAction("MD5");
        try
        {
            challengeResponse = sendAction(challengeAction);
        }
        catch (Exception e)
        {
            disconnect();
            throw new AuthenticationFailedException("Unable to send challenge action", e);
        }

        if (challengeResponse instanceof ChallengeResponse)
        {
            challenge = ((ChallengeResponse) challengeResponse).getChallenge();
        }
        else
        {
            disconnect();
            throw new AuthenticationFailedException("Unable to get challenge from Asterisk. ChallengeAction returned: "
                    + challengeResponse.getMessage());
        }

        try
        {
            MessageDigest md;

            md = MessageDigest.getInstance("MD5");
            if (challenge != null)
            {
                md.update(challenge.getBytes());
            }
            if (password != null)
            {
                md.update(password.getBytes());
            }
            key = ManagerUtil.toHexString(md.digest());
        }
        catch (NoSuchAlgorithmException ex)
        {
            disconnect();
            throw new AuthenticationFailedException("Unable to create login key using MD5 Message Digest", ex);
        }

        loginAction = new LoginAction(username, "MD5", key, eventMask);
        try
        {
            loginResponse = sendAction(loginAction);
        }
        catch (Exception e)
        {
            disconnect();
            throw new AuthenticationFailedException("Unable to send login action", e);
        }

        if (loginResponse instanceof ManagerError)
        {
            disconnect();
            throw new AuthenticationFailedException(loginResponse.getMessage());
        }

        state = CONNECTED;

        logger.info("Successfully logged in");
View Full Code Here

            return AsteriskVersion.ASTERISK_1_6;
        }

        while (attempts++ < MAX_VERSION_ATTEMPTS)
        {
            final ManagerResponse showVersionFilesResponse;
            final List<String> showVersionFilesResult;

            // increase timeout as output is quite large
            showVersionFilesResponse = sendAction(new CommandAction("show version files pbx.c"), defaultResponseTimeout * 2);
            if (!(showVersionFilesResponse instanceof CommandResponse))
View Full Code Here

        return AsteriskVersion.ASTERISK_1_6;
    }

    protected String getRawVersion()
    {
        final ManagerResponse showVersionResponse;

        try
        {
            showVersionResponse = sendAction(new CommandAction("show version"), defaultResponseTimeout * 2);
        }
View Full Code Here

                            logger.debug("buildEvent returned null");
                        }
                    }
                    else if (buffer.containsKey("response"))
                    {
                        ManagerResponse response = buildResponse(buffer);
                        // TODO tracing
                        //logger.debug("attempting to build response");
                        if (response != null)
                        {
                            dispatcher.dispatchResponse(response);
View Full Code Here

TOP

Related Classes of org.asteriskjava.manager.response.ManagerResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.