cnrg.itx.gtwy
Class Gateway

java.lang.Object
  |
  +--cnrg.itx.gtwy.Gateway

public class Gateway
extends java.lang.Object

This class contains the main Gateway control. It also creates instances of other classes needed for controlling individual Gateway channels, data flow, and the interface with signaling.


Field Summary
protected static int BUFFERSIZE
          Size of voice packets transferred from phone to Gateway.
protected static int PXFERFACTOR
          Factor BUFFERSIZE is multiplied by to determine the size of voice packets transferred from Gateway to phone.
 
Method Summary
protected  cnrg.itx.datax.Connection dialComputer(Line lineInfo, java.lang.String ext)
          Dials an computer application extension from ListenChannel.
protected  void dialPhone(java.lang.String digits, Line lineInfo)
          Used by SignalInterface to place a call to a phone.
protected  void freeLine(Line lineInfo)
          Resets and unreserves a line for a future connection.
protected  Line getAvailableLine()
          Finds a line that can be used for a connection between a computer and a phone.
protected  ChannelControl getChannelControl()
          Called to receive the ChannelControl object responsible for controlling the Gateway hardware.
protected  void hangup(Line lineInfo)
          Called by a RecordChannel.
static void main(java.lang.String[] args)
          The main entry point for the Gateway.
protected  void playDTMF(java.lang.String digits, Line lineInfo, cnrg.itx.datax.Connection c)
          Used by SignalInterface to play DTMF tones onto the connected phone.
protected  void resetSequence(Line lineInfo)
          Reinitializes a line for data flow.
protected  void sendDTMF(java.lang.String digits, Line lineInfo)
          RecordChannel calls this to send any DTMF digits it received while sending voice data from a phone to a computer.
protected  void setUpConnection(Line lineInfo, cnrg.itx.datax.Connection c)
          Sets up a data connection between phone and computer.
protected  void tearDownConnection(Line lineInfo)
          Used by SignalInterface to take down a data connection between computer and phone.
protected  void tearDownPlayConnection(Line lineInfo)
          Used by RecordChannel after a hangup to stop playout on a phone.
protected  boolean useLine(Line lineInfo)
          Checks if the specified line can be used for a connection between a phone and computer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFERSIZE

protected static final int BUFFERSIZE
Size of voice packets transferred from phone to Gateway.

PXFERFACTOR

protected static final int PXFERFACTOR
Factor BUFFERSIZE is multiplied by to determine the size of voice packets transferred from Gateway to phone.
Method Detail

getChannelControl

protected ChannelControl getChannelControl()
Called to receive the ChannelControl object responsible for controlling the Gateway hardware.
Returns:
Gateway's instance of ChannelControl.
See Also:
ChannelControl

getAvailableLine

protected Line getAvailableLine()
Finds a line that can be used for a connection between a computer and a phone. Initializes and reserves that line.
Returns:
the Line instance of the available line. Contains information concerning that line.
See Also:
Line

useLine

protected boolean useLine(Line lineInfo)
Checks if the specified line can be used for a connection between a phone and computer. If so, then the line is set offhook and reserved.
Parameters:
lineInfo - the Line instance of the specific line being reserved. Contains information concerning that line.
Returns:
true if the channel has been reserved; false otherwise.

freeLine

protected void freeLine(Line lineInfo)
Resets and unreserves a line for a future connection.
Parameters:
lineInfo - the Line instance of the line being freed. Contains information concerning that line.

resetSequence

protected void resetSequence(Line lineInfo)
Reinitializes a line for data flow.
Parameters:
lineInfo - the Line instance of the line being reinitialized. Contains information concerning that line.

setUpConnection

protected void setUpConnection(Line lineInfo,
                               cnrg.itx.datax.Connection c)
Sets up a data connection between phone and computer. The connection is always through a Gateway line.
Parameters:
lineInfo - the Line instance of the line where the connection is set up. Contains information concerning that line.
c - the Connection instance associated with the connection. Provides the means to transfer voice data.
See Also:
Connection

tearDownConnection

protected void tearDownConnection(Line lineInfo)
Used by SignalInterface to take down a data connection between computer and phone. The connection is always through a line.
Parameters:
lineInfo - the Line instance of the line where the connection currently exists. Contains information concerning the line.

tearDownPlayConnection

protected void tearDownPlayConnection(Line lineInfo)
Used by RecordChannel after a hangup to stop playout on a phone. The connection on the line is terminated.
Parameters:
lineInfo - the Line instance of the line where the connection currently exists. Contains information concerning that line.

dialComputer

protected cnrg.itx.datax.Connection dialComputer(Line lineInfo,
                                                 java.lang.String ext)
                                          throws GatewayException
Dials an computer application extension from ListenChannel. Returns when call is either accepted or rejected. If the call is accepted, a connection is then set up.
Parameters:
lineInfo - The Line instance of the line from which the phone dial is being made. Contains information concerning that line.
ext - extension number to dial.
Returns:
the Connection instance used to service data flow on a line. Provides the means necessary for voice data transfer.
Throws:
GatewayException - If extension is invalid or call has been rejected.

hangup

protected void hangup(Line lineInfo)
               throws GatewayException
Called by a RecordChannel. It informs the Gateway that the connected phone has hung up. The Gateway then informs SignalInterface.
Parameters:
lineInfo - the Line instance of the line that is disconnected. Contains information concerning that line.
Throws:
GatewayException - If the hangup fails.

sendDTMF

protected void sendDTMF(java.lang.String digits,
                        Line lineInfo)
                 throws GatewayException
RecordChannel calls this to send any DTMF digits it received while sending voice data from a phone to a computer.
Parameters:
digits - the DTMF digits that were detected from the phone.
lineInfo - the Line instance of the line on which the DTMF tones were detected.
Throws:
GatewayException - If something goes wrong in sending digits.

dialPhone

protected void dialPhone(java.lang.String digits,
                         Line lineInfo)
                  throws GatewayException
Used by SignalInterface to place a call to a phone. If phone rings, a connection through the Gateway line is created.
Parameters:
digits - the number of the phone being called
lineInfo - the Line instance of the line where the connection is to be made.
Throws:
GatewayException - If the call to a phone fails or a busy signal is received.

playDTMF

protected void playDTMF(java.lang.String digits,
                        Line lineInfo,
                        cnrg.itx.datax.Connection c)
Used by SignalInterface to play DTMF tones onto the connected phone.
Parameters:
digits - the DTMF tones being played.
lineInfo - the Line instance of the line where the DTMF tones are being played. Contains information concerning the line.
c - the Connection instance associated with the connection the line is on.

main

public static void main(java.lang.String[] args)
The main entry point for the Gateway.
Parameters:
args - Array of parameters passed to the application via the command line.