docs: public OriginateResult[] dial(final NewChannelListener listener, final EndPoint localHandset,
              final EndPoint targetEndPoint, final String dialContext, final CallerID callerID, final boolean hideCallerId,
              Map<String, String> channelVarsToSet) throws PBXException
      {
          final PBX pbx = PBXFactory.getActivePBX();
  
          try (final OriginateToExtension originate = new OriginateToExtension(listener))
          {
  
              this.startListener();
  
              // First bring the operator's handset up and connect it to the
              // 'njr-dial' extension where they can
              // wait whilst we complete the second leg
              final OriginateResult trcResult = originate.originate(localHandset, pbx.getExtensionAgi(), true,
                      ((AsteriskPBX) pbx).getManagementContext(), callerID, null, hideCallerId, channelVarsToSet);
  
              this.result[0] = trcResult;
              if (trcResult.isSuccess() == true)
              {
  
                  try
                  {
                      if (targetEndPoint instanceof HoldAtAgi)
                      {
                          if (trcResult.getChannel().waitForChannelToReachAgi(30, TimeUnit.SECONDS))
                          {
                              // call is now in agi
                              System.out.println("Call is in agi");
                          }
                          else
                          {
                              // call never reached agi
                              System.out.println("Call never reached agi");
                          }
                      }
                      else
                      {
  
                          // The call is now up, so connect it to
                          // the
                          // destination.
                          this._latch = new CountDownLatch(1);
  
                          trcResult.getChannel().setCurrentActivityAction(
                                  new AgiChannelActivityDial(targetEndPoint.getFullyQualifiedName()));
  
                          this._latch.await(30, TimeUnit.SECONDS);
  
                      }
                  }
                  catch (final InterruptedException e)
                  {
                      // noop
                  }
              }
  
              return this.result;
          }
          finally
          {
              this.close();
          }
      }