org.freeswitch.esl.client.internal
Class AbstractEslClientHandler
java.lang.Object
org.jboss.netty.channel.SimpleChannelUpstreamHandler
org.freeswitch.esl.client.internal.AbstractEslClientHandler
- All Implemented Interfaces:
- ChannelHandler, ChannelUpstreamHandler
- Direct Known Subclasses:
- AbstractOutboundClientHandler, InboundClientHandler
public abstract class AbstractEslClientHandler
- extends SimpleChannelUpstreamHandler
Specialised ChannelUpstreamHandler that implements the logic of an ESL connection that
is common to both inbound and outbound clients. This
handler expects to receive decoded EslMessage or EslEvent objects. The key
responsibilities for this class are:
-
To synthesise a synchronous command/response api. All IO operations using the underlying Netty
library are intrinsically asynchronous which provides for excellent response and scalability. This
class provides for a blocking wait mechanism for responses to commands issued to the server. A
key assumption here is that the FreeSWITCH server will process synchronous requests in the order they
are received.
-
Concrete sub classes are expected to 'terminate' the Netty IO processing pipeline (ie be the 'last'
handler).
Note: implementation requirement is that an ExecutionHandler is placed in the processing
pipeline prior to this handler. This will ensure that each incoming message is processed in its
own thread (although still guaranteed to be processed in the order of receipt).
- Author:
- david varnes
| Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler |
channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, exceptionCaught, handleUpstream, writeComplete |
MESSAGE_TERMINATOR
public static final String MESSAGE_TERMINATOR
- See Also:
- Constant Field Values
LINE_TERMINATOR
public static final String LINE_TERMINATOR
- See Also:
- Constant Field Values
AbstractEslClientHandler
public AbstractEslClientHandler()
messageReceived
public void messageReceived(ChannelHandlerContext ctx,
MessageEvent e)
throws Exception
- Overrides:
messageReceived in class SimpleChannelUpstreamHandler
- Throws:
Exception
sendSyncSingleLineCommand
public EslMessage sendSyncSingleLineCommand(Channel channel,
String command)
- Synthesise a synchronous command/response by creating a callback object which is placed in
queue and blocks waiting for another IO thread to process an incoming
EslMessage and
attach it to the callback.
- Parameters:
channel - command - single string to send
- Returns:
- the
EslMessage attached to this command's callback
sendSyncMultiLineCommand
public EslMessage sendSyncMultiLineCommand(Channel channel,
List<String> commandLines)
- Synthesise a synchronous command/response by creating a callback object which is placed in
queue and blocks waiting for another IO thread to process an incoming
EslMessage and
attach it to the callback.
- Parameters:
channel - command - List of command lines to send
- Returns:
- the
EslMessage attached to this command's callback
sendAsyncCommand
public String sendAsyncCommand(Channel channel,
String command)
- Returns the Job UUID of that the response event will have.
- Parameters:
channel - command -
- Returns:
- Job-UUID as a string
Copyright © 2009-2010 david varnes. All Rights Reserved.