Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## cnrg.itx.gtwy.pbx
Class Dialer

    java.lang.Object
      |
      +--java.lang.Thread
            |
            +--cnrg.itx.gtwy.pbx.Dialer

public class Dialer
extends java.lang.Thread

This class handles placing one call in the PBX, from a line in the Gateway to some telephone number specified by a caller

Field Summary
`private javax.telephony.Call` | `call`
`private java.lang.String` | `called`
`private java.lang.String` | `calling`
`private boolean` | `callInP`
`private javax.telephony.CallObserver` | `co`
`private javax.telephony.Connection` | `destConnection`
`private boolean` | `dialingInP`
`private boolean` | `LOG`
`private static java.lang.String` | `ME`
`private javax.telephony.Connection` | `myConnection`
`private java.net.InetAddress` | `myIAdd`
`private cnrg.itx.signal.InvitePacket` | `myPacket`
`private PBXSignaling` | `myPBX`
`private javax.telephony.Provider` | `provider`
`private java.net.Socket` | `sendSock`
`private javax.telephony.Terminal` | `terminal`
`static int` | `TIMEOUT`
`private static boolean` | `WAIT`

Fields inherited from class java.lang.Thread
`contextClassLoader, daemon, eetop, group, inheritedAccessControlContext, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadQ, values`

Constructor Summary
`Dialer(PBXSignaling p, boolean logging, cnrg.itx.signal.InvitePacket sp, java.lang.String from, java.lang.String to, java.net.Socket gs)` Base constructor for Dialer class
`Dialer(PBXSignaling p, cnrg.itx.signal.InvitePacket sp, java.lang.String from, java.lang.String to, java.net.Socket gs)` Constructor with default logging (which is none)

Method Summary
`private void` | `acceptAndWait()` This method is called to send an accept packet to the gateway and then wait for the call to finish (be hung up).
`boolean` | `callInProgress()` This method returns true if the PBX has successfully placed a call and this call is still in progress.
`private boolean` | `callPickedUp()` This method is called after a connection has been made and ringing has started.
`boolean` | `dialingInProgress()` This method returns true is the PBX is in the act of dialing a destination telephone.
`private void` | `finishCall()` This method is called when the phone has started rining.
`private void` | `hangup()` hangup() This method calls the disconnect() method of the Connection object to end the call.
`private void` | `makeCall(java.lang.String from, java.lang.String to)`
`private javax.telephony.Connection[]` | `makeOneCall(javax.telephony.Terminal t, javax.telephony.Address a, java.lang.String s, javax.telephony.Call c)` This method makes one attempt at building a connection.
`void` | `run()` This method runs the thread - this thread continues to run until the call is hungup, or the PBX Server is shut down, or placing the call failed (then we exit right away).
`private void` | `sendAcceptPacket(cnrg.itx.signal.InvitePacket ip)` This method sends an ACCEPT Result packet to the Gateway when the Dial is successfully initiated (i.e.
`private void` | `sendBusyPacket(cnrg.itx.signal.InvitePacket sp)` This method is called when a busy tone was encountered
`private void` | `sendConfirmPacket(cnrg.itx.signal.InvitePacket ip)` This method creates a CONFIRM packet and sends it back to the appropriate gateway to acknowledge that the hangup is complete March 15, 1999 - this routine might not be needed
`private boolean` | `sendPacket(cnrg.itx.signal.InvitePacket sp)` This method sends the packet back to the Gateway from which the Invite packet had been received.
`private void` | `sendRejectPacket(cnrg.itx.signal.InvitePacket ip)` This method sends a REJECT Result packet when the Dial failed
`private javax.telephony.Connection[]` | `tryMoreTimes(int n, javax.telephony.Terminal t, javax.telephony.Address a, java.lang.String s, javax.telephony.Call c)` This method makes 5 more attempts to place the call before throwing a DialingException
`private void` | `waitForPickup()` This method is called to wait for a ringing phone to be picked up before sending an accept packet back to the gateway.

Methods inherited from class java.lang.Thread
`, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, exit, getContextClassLoader, getName, getPriority, getThreadGroup, init, interrupt, interrupt0, interrupted, isAlive, isDaemon, isInterrupted, isInterrupted, join, join, join, nextThreadNum, registerNatives, resume, resume0, setContextClassLoader, setDaemon, setName, setPriority, setPriority0, sleep, sleep, start, stop, stop, stop0, suspend, suspend0, toString, yield`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### ME

    private static final java.lang.String ME

### LOG

    private boolean LOG

### WAIT

    private static final boolean WAIT

### TIMEOUT

    public static final int TIMEOUT

### myConnection

    private javax.telephony.Connection myConnection

### destConnection

    private javax.telephony.Connection destConnection

### terminal

    private javax.telephony.Terminal terminal

### provider

    private javax.telephony.Provider provider

### call

    private javax.telephony.Call call

### co

    private javax.telephony.CallObserver co

### calling

    private java.lang.String calling

### called

    private java.lang.String called

### callInP

    private boolean callInP

### dialingInP

    private boolean dialingInP

### myPBX

    private PBXSignaling myPBX

### myPacket

    private cnrg.itx.signal.InvitePacket myPacket

### myIAdd

    private java.net.InetAddress myIAdd

### sendSock

    private java.net.Socket sendSock

Constructor Detail

### Dialer

    public Dialer(PBXSignaling p,
                  boolean logging,
                  cnrg.itx.signal.InvitePacket sp,
                  java.lang.String from,
                  java.lang.String to,
                  java.net.Socket gs)
           throws DialingException

  Base constructor for Dialer class
  Parameters:
    `p` - is the PBXSignaling object that is creating this Dialer
    `logging` - is TRUE if PBX Server is logging to the terminal
    `sp` - is the InvitePacket that contains a dial request
    `from` - is the telephone number from which call will be place
    `to` - is the telephone number to be called
    `gs` - is the Socket over which our Gateway is talking to us
  Throws:
    DialingException - thrown in there is no provider

### Dialer

    public Dialer(PBXSignaling p,
                  cnrg.itx.signal.InvitePacket sp,
                  java.lang.String from,
                  java.lang.String to,
                  java.net.Socket gs)
           throws DialingException

  Constructor with default logging (which is none)
  Parameters:
    `p` - is the PBXSignaling object that is creating this Dialer
    `sp` - is the InvitePacket that contains a dial request
    `from` - is the telephone number from which call will be place
    `to` - is the telephone number to be called
    `gs` - is the Socket over which our Gateway is talking to us
  Throws:
    DialingException - thrown in there is no provider

Method Detail

### makeCall

    private void makeCall(java.lang.String from,
                          java.lang.String to)
                   throws DialingException

### tryMoreTimes

    private javax.telephony.Connection[] tryMoreTimes(int n,
                                                      javax.telephony.Terminal t,
                                                      javax.telephony.Address a,
                                                      java.lang.String s,
                                                      javax.telephony.Call c)
                                               throws DialingException

  This method makes 5 more attempts to place the call before throwing a DialingException
  Parameters:
    `n` - is the number of tries to make
    `t` - is the Terminal that is making the call
    `a` - is the Address corresponding to `t`
    `s` - is the String form of the destination telephone number
    `c` - is the Call whose connect method we will call
  Throws:
    DialingException - if caller does not go off-hook

### makeOneCall

    private javax.telephony.Connection[] makeOneCall(javax.telephony.Terminal t,
                                                     javax.telephony.Address a,
                                                     java.lang.String s,
                                                     javax.telephony.Call c)
                                              throws DialingException,
                                                     javax.telephony.InvalidStateException

  This method makes one attempt at building a connection. First it checks to see that our provider is in service and makes one attempt to resuscitate it if it is not in service.
  Parameters:
    `t` - is the Terminal that is making the call
    `a` - is the Address corresponding to `t`
    `s` - is the String form of the destination telephone number
    `c` - is the Call whose connect method we will call
  Throws:
    DialingException - if Call.connect() fails
    javax.telephony.InvalidStateException - if caller is not off-hook

### hangup

    private void hangup()

  hangup() This method calls the disconnect() method of the Connection object to end the call. Also, it removes the callObserver

### run

    public void run()

  This method runs the thread - this thread continues to run until the call is hungup, or the PBX Server is shut down, or placing the call failed (then we exit right away).
  Overrides:
    run in class java.lang.Thread

### callInProgress

    public boolean callInProgress()

  This method returns true if the PBX has successfully placed a call and this call is still in progress.
  Returns:
    true if call is still in progress

### dialingInProgress

    public boolean dialingInProgress()

  This method returns true is the PBX is in the act of dialing a destination telephone. The call has not yet been established.
  Returns:
    true is PBX is dialing a number

### sendConfirmPacket

    private void sendConfirmPacket(cnrg.itx.signal.InvitePacket ip)
                            throws PBXSignalingException

  This method creates a CONFIRM packet and sends it back to the appropriate gateway to acknowledge that the hangup is complete March 15, 1999 - this routine might not be needed
  Returns:
    void

### sendBusyPacket

    private void sendBusyPacket(cnrg.itx.signal.InvitePacket sp)

  This method is called when a busy tone was encountered
  Parameters:
    `sp` - is the InvitePacket that originally caused us to ring this phone
  Returns:
    void

### sendAcceptPacket

    private void sendAcceptPacket(cnrg.itx.signal.InvitePacket ip)

  This method sends an ACCEPT Result packet to the Gateway when the Dial is successfully initiated (i.e. telephone at other end is ringing) and then the phone was picked up within TIMEOUT msecs
  Parameters:
    `ip` - The InvitePacket that we were using to dial with

### sendRejectPacket

    private void sendRejectPacket(cnrg.itx.signal.InvitePacket ip)

  This method sends a REJECT Result packet when the Dial failed
  Parameters:
    `ip` - The InvitePacket that we were using to dial with

### sendPacket

    private boolean sendPacket(cnrg.itx.signal.InvitePacket sp)

  This method sends the packet back to the Gateway from which the Invite packet had been received. [WAS: where it came from.] A new socket is created. The packet's fields have already been appropriately adjusted.
  Parameters:
    `sp` - The packet to be sent
  Returns:
    true if packet was successfully sent, false otherwise

### callPickedUp

    private boolean callPickedUp()

  This method is called after a connection has been made and ringing has started. The goal now is to wait for a Connection.CONNECTED state. Check every second. Connection.ALERTING probably means the phone is ringing Connection.FAILED probably means the phone is busy This routine sends an accept, busy, or reject, depending on circumstances
  Returns:
    false if timeout, true if call picked up

### finishCall

    private void finishCall()

  This method is called when the phone has started rining. We have a call in progress. We don't know whether it will be picked up or if the ringing terminal is already busy. If the call is accepted, Dialer thread hangs here until the hangup request comes in. Otherwise we send a BUSY or REJECT and die now.

### waitForPickup

    private void waitForPickup()

  This method is called to wait for a ringing phone to be picked up before sending an accept packet back to the gateway. Upon entry to this method, dialingInP = false, callInP = false

### acceptAndWait

    private void acceptAndWait()

  This method is called to send an accept packet to the gateway and then wait for the call to finish (be hung up).

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD