Examples of AgiReply


Examples of org.asteriskjava.fastagi.reply.AgiReply

        writer.sendCommand(command);

        AgiClientChannel channel = new AgiClientChannelImpl(writer);

        while (!Thread.interrupted()) {
          AgiReply reply = reader.readReply();
          _script.service(reply, channel);
        }
      } catch (AgiException e) {
        e.printStackTrace();
      } finally {
View Full Code Here

Examples of org.asteriskjava.fastagi.reply.AgiReply

    }

    @Test
    public void testReadReply() throws Exception
    {
        AgiReply reply;

        expect(socket.readLine()).andReturn("200 result=49 endpos=2240");

        replay(socket);

        reply = agiReader.readReply();

        assertEquals("Incorrect status", AgiReply.SC_SUCCESS, reply.getStatus());
        assertEquals("Incorrect result", 49, reply.getResultCode());

        verify(socket);
    }
View Full Code Here

Examples of org.asteriskjava.fastagi.reply.AgiReply

    }

    @Test
    public void testReadReplyInvalidOrUnknownCommand() throws Exception
    {
        AgiReply reply;

        expect(socket.readLine()).andReturn("510 Invalid or unknown command");

        replay(socket);

        reply = agiReader.readReply();

        assertEquals("Incorrect status", AgiReply.SC_INVALID_OR_UNKNOWN_COMMAND, reply.getStatus());

        verify(socket);
    }
View Full Code Here

Examples of org.asteriskjava.fastagi.reply.AgiReply

    }

    @Test
    public void testReadReplyInvalidCommandSyntax() throws Exception
    {
        AgiReply reply;

        expect(socket.readLine()).andReturn("520-Invalid command syntax.  Proper usage follows:");
        expect(socket.readLine()).andReturn(" Usage: DATABASE DEL <family> <key>");
        expect(socket.readLine()).andReturn("        Deletes an entry in the Asterisk database for a");
        expect(socket.readLine()).andReturn(" given family and key.");
        expect(socket.readLine()).andReturn(" Returns 1 if succesful, 0 otherwise");
        expect(socket.readLine()).andReturn("520 End of proper usage.");

        replay(socket);

        reply = agiReader.readReply();

        assertEquals("Incorrect status", AgiReply.SC_INVALID_COMMAND_SYNTAX, reply.getStatus());
        assertEquals("Incorrect synopsis", "DATABASE DEL <family> <key>", reply.getSynopsis());

        verify(socket);
    }
View Full Code Here

Examples of org.asteriskjava.fastagi.reply.AgiReply

        return request;
    }

    public AgiReply readReply() throws AgiException
    {
        AgiReply reply;
        List<String> lines;
        String line;

        lines = new ArrayList<String>();

        try
        {
            line = socket.readLine();
        }
        catch (IOException e)
        {
            // readline throws IOException if the connection has been closed
            throw new AgiHangupException();
        }

        if (line == null)
        {
            throw new AgiHangupException();
        }

        // TODO Asterisk 1.6 sends "HANGUP" when the channel is hung up.
        //System.out.println(line);
        if (line.startsWith("HANGUP"))
        {
            if (line.length() > 6)
            {
                line = line.substring(6);
            }
            else
            {
                return readReply();
            }
        }

        lines.add(line);

        // read synopsis and usage if statuscode is 520
        if (line.startsWith(Integer.toString(AgiReply.SC_INVALID_COMMAND_SYNTAX)))
        {
            try
            {
                while ((line = socket.readLine()) != null)
                {
                    lines.add(line);
                    if (line.startsWith(Integer.toString(AgiReply.SC_INVALID_COMMAND_SYNTAX)))
                    {
                        break;
                    }
                }
            }
            catch (IOException e)
            {
                throw new AgiNetworkException("Unable to read reply from Asterisk: " + e.getMessage(), e);
            }
        }

        reply = new AgiReplyImpl(lines);

        // Special handling for gosub, see AJ-257
        if (reply.getStatus() == AgiReply.SC_TRYING)
        {
          return readReply();
        }
        else
        {
View Full Code Here

Examples of org.asteriskjava.fastagi.reply.AgiReply

        if ("hangup".equals(lastReply.getExtra()))
        {
            throw new AgiHangupException();
        }
        final AgiReply speechRecognizeReply = lastReply;
        return new SpeechRecognitionResult(speechRecognizeReply);
    }
View Full Code Here

Examples of org.asteriskjava.fastagi.reply.AgiReply

        return request;
    }

    public AgiReply readReply() throws AgiException
    {
        AgiReply reply;
        List<String> lines;
        String line;

        lines = new ArrayList<String>();
View Full Code Here

Examples of org.asteriskjava.fastagi.reply.AgiReply

        if ("hangup".equals(lastReply.getExtra()))
        {
            throw new AgiHangupException();
        }
        final AgiReply speechRecognizeReply = lastReply;
        return new SpeechRecognitionResult(speechRecognizeReply);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.