org.mobicents.protocols.smpp.net
Class ReplayLink

java.lang.Object
  extended by org.mobicents.protocols.smpp.net.ReplayLink
All Implemented Interfaces:
SmscLink

public class ReplayLink
extends Object
implements SmscLink

An implementation of the SmscLink interface which can be used to replay an SMPP session.

This implementation is intended to be used in conjunction with data captured from a real SMPP session. All outbound bytes should be captured in one location and all inbound bytes in another. This link will reconstitute the SMPP packets for the session and provide response packets only after it has seen the request packets being sent.

Version:
$Id: ReplayLink.java 457 2009-01-15 17:37:42Z orank $

Constructor Summary
ReplayLink(InputStream inPacketSource, InputStream outPacketSource)
           
 
Method Summary
 void connect()
          Initiate the connection to the SMSC.
 void disconnect()
          Disconnect from the SMSC.
 void flush()
          If the underlying link implements some form of output buffering, then this method should flush the buffer.
 SMPPPacket getNextOutbound()
           
 int getTimeout()
          Get the current timeout for the underlying link.
 boolean isConnected()
          Determine if the underlying link is connected to the SMSC.
 boolean isTimeoutSupported()
          Determine if this SMSC link supports read timeouts.
 SMPPPacket read()
          Read the next SMPP packet from the underlying link.
 void setTimeout(int timeout)
          Set the read timeout for the underlying link.
 void write(SMPPPacket packet, boolean withOptionalParams)
          Send an SMPP packet to the SMSC.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplayLink

public ReplayLink(InputStream inPacketSource,
                  InputStream outPacketSource)
Method Detail

connect

public void connect()
             throws IOException
Description copied from interface: SmscLink
Initiate the connection to the SMSC. If this link is already connected, this method should do nothing.

Specified by:
connect in interface SmscLink
Throws:
IOException

disconnect

public void disconnect()
                throws IOException
Description copied from interface: SmscLink
Disconnect from the SMSC. If this link is already closed, this method should do nothing.

Specified by:
disconnect in interface SmscLink
Throws:
IOException

flush

public void flush()
           throws IOException
Description copied from interface: SmscLink
If the underlying link implements some form of output buffering, then this method should flush the buffer. If the link does not do any form of buffering, this method should do nothing.

Specified by:
flush in interface SmscLink
Throws:
IOException

getTimeout

public int getTimeout()
Description copied from interface: SmscLink
Get the current timeout for the underlying link. If read timeouts are not supported, calls to this method should throw a UnsupportedOperationException.

Specified by:
getTimeout in interface SmscLink
Returns:
The current timeout, specified in milliseconds.
See Also:
SmscLink.setTimeout(int)

setTimeout

public void setTimeout(int timeout)
Description copied from interface: SmscLink
Set the read timeout for the underlying link. If a blocked read takes longer than the specified timeout, then a ReadTimeoutException should be thrown. Supporting read timeouts is optional for SmscLink implementations. If it is not supported, calls to this method must throw an UnsupportedOperationException. A timeout value of 0 deactivates timeouts - reads will block forever.

Specified by:
setTimeout in interface SmscLink
Parameters:
timeout - The new timeout value, specified in milliseconds.

isConnected

public boolean isConnected()
Description copied from interface: SmscLink
Determine if the underlying link is connected to the SMSC.

Specified by:
isConnected in interface SmscLink
Returns:
true if connected, false otherwise.

isTimeoutSupported

public boolean isTimeoutSupported()
Description copied from interface: SmscLink
Determine if this SMSC link supports read timeouts.

Specified by:
isTimeoutSupported in interface SmscLink
Returns:
true if the implementation supports read timeouts, false if not.

getNextOutbound

public SMPPPacket getNextOutbound()
                           throws IOException
Throws:
IOException

read

public SMPPPacket read()
                throws IOException
Description copied from interface: SmscLink
Read the next SMPP packet from the underlying link. This method should block until it has fully read all of the bytes for the next packet, barring any time out. The byte array supplied to the method call will be used to store the packet's bytes, and that same array will be returned. However, if the buffer is not large enough to hold the packet, a new byte array will be created, the packet stored in it and this new array will be returned.

Specified by:
read in interface SmscLink
Returns:
buffer will be returned if it is large enough to hold all of the packet's data, otherwise a new array is created and returned with the packet data.
Throws:
IOException

write

public void write(SMPPPacket packet,
                  boolean withOptionalParams)
           throws IOException
Description copied from interface: SmscLink
Send an SMPP packet to the SMSC.

Specified by:
write in interface SmscLink
Parameters:
packet - The packet to send.
withOptionalParams - true to send the packet's optional parameters during the write, false to omit the optional parameters.
Throws:
IOException


Copyright © 2011 Mobicents. All Rights Reserved.