public void sendBye(String localSipURL, String remoteSipURL, ChatSession chatSession) {
    // Send a Bye only if there were exchanged messages!!!
    if (chatSession.isEstablishedSession()) {
      try {
        logger.debug("Sending a BYE in progress to " + remoteSipURL);

        SipProvider sipProvider = imUA.getSipProvider();

        javax.sip.Dialog dialog = chatSession.getDialog();

        Request request = dialog.createRequest(Request.BYE);

        // ProxyAuthorization header if not null:
        ProxyAuthorizationHeader proxyAuthHeader = imUA.getProxyAuthorizationHeader();
        if (proxyAuthHeader != null) request.setHeader(proxyAuthHeader);

        ClientTransaction clientTransaction = sipProvider.getNewClientTransaction(request);

        dialog.sendRequest(clientTransaction);
        logger.debug("BYE sent:\n" + request);

      } catch (Exception ex) {
        ex.printStackTrace();
      }
    } else {
      logger.debug("BYE not sent because of no exchanged messages!!!");
    }
  }
Esempio n. 2
0
 private int cancelAllRequests(@NotNull List<Request> list) {
   int count = 0;
   for (Request request : list) {
     count++;
     request.cancel();
   }
   list.clear();
   return count;
 }
Esempio n. 3
0
 private void cancelRequest(@NotNull Runnable request, @NotNull List<Request> list) {
   for (int i = list.size() - 1; i >= 0; i--) {
     Request r = list.get(i);
     if (r.getTask() == request) {
       r.cancel();
       list.remove(i);
     }
   }
 }
Esempio n. 4
0
 private void _add(@NotNull Request requestToSchedule) {
   final ScheduledFuture<?> future =
       JobScheduler.getScheduler()
           .schedule(requestToSchedule, requestToSchedule.myDelay, TimeUnit.MILLISECONDS);
   requestToSchedule.setFuture(future);
   myRequests.add(requestToSchedule);
 }