/** Exit the proxy, throws Exception that which can be caught by the upper application */
  public void exit() throws Exception {
    Iterator sipProviders = sipStack.getSipProviders();
    if (sipProviders != null) {
      while (sipProviders.hasNext()) {
        SipProvider sp = (SipProvider) sipProviders.next();
        sp.removeSipListener(this);
        sipStack.deleteSipProvider(sp);
        sipProviders = sipStack.getSipProviders();
        System.out.println("One sip Provider removed!");
      }
    } else {
      ProxyDebug.println("WARNING, STOP_PROXY, The proxy " + " has no sip Provider to remove!");
    }

    Iterator listeningPoints = sipStack.getListeningPoints();
    if (listeningPoints != null) {
      while (listeningPoints.hasNext()) {
        ListeningPoint lp = (ListeningPoint) listeningPoints.next();
        sipStack.deleteListeningPoint(lp);
        listeningPoints = sipStack.getListeningPoints();
        System.out.println("One listening point removed!");
      }
    } else {
      ProxyDebug.println("WARNING, STOP_PROXY, The proxy " + " has no listening points to remove!");
    }
    ProxyDebug.println("Proxy exit.........................");
    configuration.listeningPoints.clear();
    registrar.clean();
  }
  /**
   * Stop the proxy, this method has to be called after the start method throws Exception that which
   * can be caught by the upper application
   */
  public void stop() throws Exception {
    if (sipStack == null) return;
    this.presenceServer.stop();

    Iterator sipProviders = sipStack.getSipProviders();
    if (sipProviders != null) {
      while (sipProviders.hasNext()) {
        SipProvider sp = (SipProvider) sipProviders.next();
        sp.removeSipListener(this);
        sipStack.deleteSipProvider(sp);
        sipProviders = sipStack.getSipProviders();
        System.out.println("One sip Provider removed!");
      }
    } else {
      ProxyDebug.println("WARNING, STOP_PROXY, The proxy " + " has no sip Provider to remove!");
    }

    Iterator listeningPoints = sipStack.getListeningPoints();
    if (listeningPoints != null) {
      while (listeningPoints.hasNext()) {
        ListeningPoint lp = (ListeningPoint) listeningPoints.next();
        sipStack.deleteListeningPoint(lp);
        listeningPoints = sipStack.getListeningPoints();
        System.out.println("One listening point removed!");
      }
    } else {
      ProxyDebug.println("WARNING, STOP_PROXY, The proxy " + " has no listening points to remove!");
    }
    registrar.clean();
  }
 public void setOff(SipStack mySipStack) {
   /// System.out.println("=> BUNDLE: br.ufes.inf.ngn.televoto.client.logic | CLASS: LogicListener
   // | METOD: setOff ");//By Ju
   try {
     mySipProvider.removeSipListener(this);
     mySipProvider.removeListeningPoint(myListeningPoint);
     mySipStack.deleteListeningPoint(myListeningPoint);
     mySipStack.deleteSipProvider(mySipProvider);
     myListeningPoint = null;
     mySipProvider = null;
     mySipStack = null;
     // myRingTool=null;
     myTimer.cancel();
     System.out.println("Finalizado...");
   } catch (Exception e) {
   }
 }
Beispiel #4
0
 private void shutDown() {
   try {
     try {
       Thread.sleep(2000);
     } catch (InterruptedException e) {
     }
     System.out.println("nulling reference");
     sipStack.deleteListeningPoint(tcpListeningPoint);
     sipStack.deleteListeningPoint(udpListeningPoint);
     // This will close down the stack and exit all threads
     tcpProvider.removeSipListener(this);
     udpProvider.removeSipListener(this);
     while (true) {
       try {
         sipStack.deleteSipProvider(udpProvider);
         sipStack.deleteSipProvider(tcpProvider);
         break;
       } catch (ObjectInUseException ex) {
         try {
           Thread.sleep(2000);
         } catch (InterruptedException e) {
           continue;
         }
       }
     }
     sipStack = null;
     tcpProvider = null;
     udpProvider = null;
     this.contactHeader = null;
     addressFactory = null;
     headerFactory = null;
     messageFactory = null;
     this.udpListeningPoint = null;
     this.tcpListeningPoint = null;
     this.reInviteCount = 0;
     System.gc();
     // Redo this from the start.
     if (counter < 10) this.init();
     else counter++;
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
  public static void stopSipStack(SipStack sipStack, SipListener listener) {
    Iterator<SipProvider> sipProviderIterator = sipStack.getSipProviders();
    try {
      while (sipProviderIterator.hasNext()) {
        SipProvider sipProvider = sipProviderIterator.next();
        ListeningPoint[] listeningPoints = sipProvider.getListeningPoints();
        for (ListeningPoint listeningPoint : listeningPoints) {
          sipProvider.removeListeningPoint(listeningPoint);
          sipStack.deleteListeningPoint(listeningPoint);
          listeningPoints = sipProvider.getListeningPoints();
        }
        sipProvider.removeSipListener(listener);
        sipStack.deleteSipProvider(sipProvider);
        sipProviderIterator = sipStack.getSipProviders();
      }
    } catch (Exception e) {
      throw new IllegalStateException("Cant remove the listening points or sip providers", e);
    }

    sipStack.stop();
    sipStack = null;
  }