Search in sources :

Example 16 with TransactionUnavailableException

use of javax.sip.TransactionUnavailableException in project load-balancer by RestComm.

the class TestSipListener method sendBye.

/**
 * @throws SipException
 * @throws TransactionUnavailableException
 * @throws TransactionDoesNotExistException
 */
public void sendBye(final Dialog dialog) throws SipException, TransactionUnavailableException, TransactionDoesNotExistException {
    Thread th = new Thread() {

        public void run() {
            try {
                if (sendByeInNewThread)
                    Thread.sleep(600);
                Request byeRequest = dialog.createRequest(Request.BYE);
                URI uri = ((FromHeader) byeRequest.getHeader(FromHeader.NAME)).getAddress().getURI();
                if (uri.isSipURI()) {
                    ((SipURI) uri).removeParameter("fromParam");
                }
                ClientTransaction ct = sipProvider.getNewClientTransaction(byeRequest);
                logger.info("Sending BYE " + byeRequest);
                if (!sendSubsequentRequestsThroughSipProvider) {
                    dialog.sendRequest(ct);
                } else {
                    sipProvider.sendRequest(byeRequest);
                }
                byeSent = true;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };
    if (sendByeInNewThread) {
        th.start();
    } else {
        th.run();
    }
}
Also used : ClientTransaction(javax.sip.ClientTransaction) Request(javax.sip.message.Request) SipURI(javax.sip.address.SipURI) URI(javax.sip.address.URI) SipURI(javax.sip.address.SipURI) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) SipException(javax.sip.SipException) TransactionDoesNotExistException(javax.sip.TransactionDoesNotExistException) TransactionUnavailableException(javax.sip.TransactionUnavailableException)

Aggregations

ParseException (java.text.ParseException)16 TransactionUnavailableException (javax.sip.TransactionUnavailableException)16 SipException (javax.sip.SipException)15 InvalidArgumentException (javax.sip.InvalidArgumentException)14 Request (javax.sip.message.Request)12 ClientTransaction (javax.sip.ClientTransaction)9 CallIdHeader (javax.sip.header.CallIdHeader)8 ViaHeader (javax.sip.header.ViaHeader)8 ContactHeader (javax.sip.header.ContactHeader)7 FromHeader (javax.sip.header.FromHeader)7 MaxForwardsHeader (javax.sip.header.MaxForwardsHeader)7 ToHeader (javax.sip.header.ToHeader)7 URI (javax.sip.address.URI)6 CSeqHeader (javax.sip.header.CSeqHeader)6 SipSecurityException (net.java.sipmack.sip.security.SipSecurityException)6 PeerUnavailableException (javax.sip.PeerUnavailableException)5 Address (javax.sip.address.Address)5 SipURI (javax.sip.address.SipURI)5 TransactionAlreadyExistsException (javax.sip.TransactionAlreadyExistsException)4 ContentTypeHeader (javax.sip.header.ContentTypeHeader)4