org.freeswitch.esl.client.internal
Class AbstractEslClientHandler

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by 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:

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
 
Field Summary
static String LINE_TERMINATOR
           
static String MESSAGE_TERMINATOR
           
 
Constructor Summary
AbstractEslClientHandler()
           
 
Method Summary
 void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
           
 String sendAsyncCommand(Channel channel, String command)
          Returns the Job UUID of that the response event will have.
 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.
 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.
 
Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler
channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, exceptionCaught, handleUpstream, writeComplete
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

AbstractEslClientHandler

public AbstractEslClientHandler()
Method Detail

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.