org.mobicents.protocols.smpp.net
Interface SmscLink

All Known Implementing Classes:
AbstractStreamLink, ObjectLink, ReplayLink, TcpLink

public interface SmscLink

Interface for the network link to an SMSC.

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

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.
 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.
 

Method Detail

connect

void connect()
             throws IOException
Initiate the connection to the SMSC. If this link is already connected, this method should do nothing.

Throws:
IOException

disconnect

void disconnect()
                throws IOException
Disconnect from the SMSC. If this link is already closed, this method should do nothing.

Throws:
IOException

isConnected

boolean isConnected()
Determine if the underlying link is connected to the SMSC.

Returns:
true if connected, false otherwise.

write

void write(SMPPPacket packet,
           boolean withOptionalParams)
           throws IOException
Send an SMPP packet to the SMSC.

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

flush

void flush()
           throws IOException
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.

Throws:
IOException

read

SMPPPacket read()
                throws IOException
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.

Parameters:
buffer - A byte array to use to store the packet data.
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
ReadTimeoutException

getTimeout

int getTimeout()
Get the current timeout for the underlying link. If read timeouts are not supported, calls to this method should throw a UnsupportedOperationException.

Returns:
The current timeout, specified in milliseconds.
Throws:
UnsupportedOperationException - If read timeouts are not supported.
See Also:
setTimeout(int)

setTimeout

void setTimeout(int timeout)
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.

Parameters:
timeout - The new timeout value, specified in milliseconds.
Throws:
UnsupportedOperationException - If read timeouts are not supported.

isTimeoutSupported

boolean isTimeoutSupported()
Determine if this SMSC link supports read timeouts.

Returns:
true if the implementation supports read timeouts, false if not.


Copyright © 2011 Mobicents. All Rights Reserved.