Answering a call

To answer a call, you:

  1. Get the ring notification.
    One way to do this is to set up a special class to receive the ring notification.
  2. Call CreateAndAnswerCall to answer the call.
    To determine whether the call connects, call GetStatus on the call handle.
      class TRingHandler
      {
      public:
                      TRingHandler (const TTelephoneLineHandle*);
      virtual         ~TRingHandler ();
      virtual void    HandleRing(const TTelephoneRingNotification&);
      
      private:
      
      TTelephoneLineHandle*   fLineHandle;
      TTelephoneCallHandle*   fCallHandle;
      TMemberFunctionConnection   fConnection;
      };
      
      // Implement TRingHandler. 
      TRingHandler::TRingHandler(const TTelephoneLineHandle* lineHandle)
                         : fLineHandle(lineHandle)
      {
            fConnection.SetReceiver(this, (NotificationMemberFunction)
                  &TRingHandler::HandleRing);
          fConnection.AdoptInterest(fLineHandle->CreateRingInterest());
          fConnection.Connect();
      }
      
      TRingHandler::~TRingHandler()
      {
      delete fCallHandle;
      delete fLineHandle;
      }
      TRingHandler::HandleRing(const TNotification& ringNotification)
      {
      // If the phone system supports calling party ID, before the
      // call is connected you can ask who is calling
          TStandardText callingParty;
          ((const TTelephoneRingNotification&) 
                      theNotification).GetIncomingNumber(callingParty);
      
          // Answer the call
          fCallHandle = fLineHandle->CreateAndAnswerCall();
      }

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker