[Asterisk-java-cvs] CVS: asterisk-java/src/java/net/sf/asterisk/fastagi AGIChannelImpl.java,NONE,1.1
Brought to you by:
srt
From: Stefan R. <sr...@us...> - 2005-03-11 01:17:13
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15391/src/java/net/sf/asterisk/fastagi Modified Files: AGIConnectionHandler.java AGIScript.java Added Files: AGIChannelImpl.java AbstractAGIScript.java AGIChannel.java Removed Files: AGIResponse.java AGIResponseImpl.java Log Message: Renamed AGIResponse to AGIChannel --- NEW FILE: AGIChannelImpl.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi; import java.io.IOException; import net.sf.asterisk.fastagi.command.AGICommand; import net.sf.asterisk.fastagi.reply.AGIReply; import net.sf.asterisk.io.SocketConnectionFacade; /** * Default implementation of the AGIChannel interface. * * @author srt * @version $Id: AGIChannelImpl.java,v 1.1 2005/03/10 23:57:06 srt Exp $ */ public class AGIChannelImpl implements AGIChannel { private AGIWriter agiWriter; private AGIReader agiReader; private SocketConnectionFacade socket; public AGIChannelImpl(SocketConnectionFacade socket) { this.socket = socket; this.agiWriter = new AGIWriterImpl(socket); this.agiReader = new AGIReaderImpl(socket); } public AGIChannelImpl(AGIWriter agiWriter, AGIReader agiReader) { this.agiWriter = agiWriter; this.agiReader = agiReader; } public synchronized AGIReply sendCommand(AGICommand command) throws IOException { AGIReply reply; agiWriter.sendCommand(command); reply = agiReader.readReply(); return reply; } } --- NEW FILE: AbstractAGIScript.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi; import java.io.IOException; import net.sf.asterisk.fastagi.command.AnswerCommand; import net.sf.asterisk.fastagi.command.HangupCommand; /** * The AbstractAGIScript provides some convinience methods to make it easier to * write custom AGIScripts. * * @author srt * @version $Id: AbstractAGIScript.java,v 1.1 2005/03/10 23:57:06 srt Exp $ */ public abstract class AbstractAGIScript implements AGIScript { /** * Answers the channel. * * @param channel the channel as received by the service method. * @throws IOException if the command can't be sent to Asterisk. */ protected void answer(AGIChannel channel) throws IOException { channel.sendCommand(new AnswerCommand()); } /** * Hangs the channel up. * * @param channel the channel as received by the service method. * @throws IOException if the command can't be sent to Asterisk. */ protected void hangup(AGIChannel channel) throws IOException { channel.sendCommand(new HangupCommand()); } } --- NEW FILE: AGIChannel.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi; import java.io.IOException; import net.sf.asterisk.fastagi.command.AGICommand; import net.sf.asterisk.fastagi.reply.AGIReply; /** * Provides the functionality to send AGICommands to Asterisk while handling an * AGIRequest.<br> * This interface is supposed to be used by AGIScripts for interaction with the * Asterisk server. * * @author srt * @version $Id: AGIChannel.java,v 1.1 2005/03/10 23:57:06 srt Exp $ */ public interface AGIChannel { /** * Sends a command to asterisk and returns the corresponding reply. * * @param command the command to send. * @return the reply of the asterisk server containing the return value. * * @throws IOException if there is a problem sending the command. */ AGIReply sendCommand(AGICommand command) throws IOException; } Index: AGIConnectionHandler.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIConnectionHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- AGIConnectionHandler.java 10 Mar 2005 23:34:13 -0000 1.3 +++ AGIConnectionHandler.java 10 Mar 2005 23:57:06 -0000 1.4 @@ -77,21 +77,21 @@ public class AGIConnectionHandler implem AGIReader reader; AGIWriter writer; AGIRequest request; - AGIResponse response; + AGIChannel channel; AGIScript script; reader = createReader(); writer = createWriter(); request = reader.readRequest(); - response = new AGIResponseImpl(writer, reader); + channel = new AGIChannelImpl(writer, reader); script = mappingStrategy.determineScript(request); if (script != null) { logger.info("Running AGIScript " + script.getClass().getName()); - script.service(request, response); + script.service(request, channel); } else { Index: AGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIScript.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- AGIScript.java 10 Mar 2005 23:35:04 -0000 1.3 +++ AGIScript.java 10 Mar 2005 23:57:06 -0000 1.4 @@ -37,9 +37,9 @@ public interface AGIScript * * @param request the initial data received from Asterisk when requesting * this script. - * @param response a handle to communicate with Asterisk such as sending - * commands in response to the request. + * @param channel a handle to communicate with Asterisk such as sending + * commands to the channel sending the request. * @throws IOException if there is a problem with the network connection. */ - void service(final AGIRequest request, final AGIResponse response) throws IOException; + void service(final AGIRequest request, final AGIChannel channel) throws IOException; } --- AGIResponse.java DELETED --- --- AGIResponseImpl.java DELETED --- |