Search in sources :

Example 1 with JoinHeader

use of gov.nist.javax.sip.header.extensions.JoinHeader in project load-balancer by RestComm.

the class TestSipListener method processAck.

public void processAck(Request request, ServerTransaction serverTransactionId) {
    try {
        logger.info("shootist:  got a " + request);
        logger.info("shootist:  got an ACK. ServerTxId = " + serverTransactionId);
        ackReceived = true;
        // we don't count retransmissions
        if (serverTransactionId != null) {
            ackCount++;
        }
        if (testAckViaParam) {
            ViaHeader viaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
            String param = viaHeader.getParameter("testAckViaParam");
            if (param != null) {
                abortProcessing = true;
                logger.error("the Via Param set in the response shouldn't be present in the ACK");
                return;
            }
        }
        if (sendBye) {
            Thread.sleep(timeToWaitBeforeBye);
            if (serverTransactionId != null && serverTransactionId.getDialog() != null) {
                Request byeRequest = serverTransactionId.getDialog().createRequest(Request.BYE);
                logger.info("BYE created : " + byeRequest);
                ClientTransaction ct = sipProvider.getNewClientTransaction(byeRequest);
                logger.info("Sending BYE : " + byeRequest);
                serverTransactionId.getDialog().sendRequest(ct);
                logger.info("Dialog State = " + serverTransactionId.getDialog().getState());
            }
        }
        if (!joinRequestReceived && sendJoinMessage) {
            String fromUser = "join";
            String fromHost = "sip-servlets.com";
            SipURI fromAddress = protocolObjects.addressFactory.createSipURI(fromUser, fromHost);
            String toUser = "join-receiver";
            String toHost = "sip-servlets.com";
            SipURI toAddress = protocolObjects.addressFactory.createSipURI(toUser, toHost);
            CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME);
            FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME);
            ToHeader toHeader = (ToHeader) request.getHeader(ToHeader.NAME);
            JoinHeader joinHeader = (JoinHeader) ((HeaderFactoryExt) protocolObjects.headerFactory).createJoinHeader(callIdHeader.getCallId(), toHeader.getTag(), fromHeader.getTag());
            sendSipRequest("MESSAGE", fromAddress, toAddress, joinHeader.toString(), null, false);
        }
        if (!isReplacesRequestReceived() && sendReplacesMessage) {
            String fromUser = "replaces";
            String fromHost = "sip-servlets.com";
            SipURI fromAddress = protocolObjects.addressFactory.createSipURI(fromUser, fromHost);
            String toUser = "replaces-receiver";
            String toHost = "sip-servlets.com";
            SipURI toAddress = protocolObjects.addressFactory.createSipURI(toUser, toHost);
            CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME);
            FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME);
            ToHeader toHeader = (ToHeader) request.getHeader(ToHeader.NAME);
            ReplacesHeader replacesHeader = (ReplacesHeader) ((HeaderFactoryExt) protocolObjects.headerFactory).createReplacesHeader(callIdHeader.getCallId(), toHeader.getTag(), fromHeader.getTag());
            sendSipRequest("MESSAGE", fromAddress, toAddress, replacesHeader.toString(), null, false);
        }
        if (joinRequestReceived) {
            sendBye();
            sendBye(joinDialog);
        }
        if (isReplacesRequestReceived()) {
            sendBye();
            sendBye(replacesDialog);
        }
        if (sendReinvite && !reinviteSent) {
            List<Header> headers = new ArrayList<Header>();
            Header reinviteHeader = protocolObjects.headerFactory.createHeader("ReInvite", "true");
            headers.add(reinviteHeader);
            sendInDialogSipRequest("INVITE", null, null, null, headers, null);
            reinviteSent = true;
            return;
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : FromHeader(javax.sip.header.FromHeader) ClientTransaction(javax.sip.ClientTransaction) Request(javax.sip.message.Request) ArrayList(java.util.ArrayList) 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) ReasonHeader(javax.sip.header.ReasonHeader) RequireHeader(javax.sip.header.RequireHeader) SIPETagHeader(javax.sip.header.SIPETagHeader) ContactHeader(javax.sip.header.ContactHeader) ReferToHeader(javax.sip.header.ReferToHeader) ViaHeader(javax.sip.header.ViaHeader) SIPIfMatchHeader(javax.sip.header.SIPIfMatchHeader) AuthorizationHeader(javax.sip.header.AuthorizationHeader) CallIdHeader(javax.sip.header.CallIdHeader) ContentLengthHeader(javax.sip.header.ContentLengthHeader) ExtensionHeader(javax.sip.header.ExtensionHeader) ExpiresHeader(javax.sip.header.ExpiresHeader) Header(javax.sip.header.Header) ReplacesHeader(gov.nist.javax.sip.header.extensions.ReplacesHeader) CSeqHeader(javax.sip.header.CSeqHeader) ContentTypeHeader(javax.sip.header.ContentTypeHeader) JoinHeader(gov.nist.javax.sip.header.extensions.JoinHeader) MaxForwardsHeader(javax.sip.header.MaxForwardsHeader) ToHeader(javax.sip.header.ToHeader) RouteHeader(javax.sip.header.RouteHeader) ProxyAuthorizationHeader(javax.sip.header.ProxyAuthorizationHeader) SubscriptionStateHeader(javax.sip.header.SubscriptionStateHeader) EventHeader(javax.sip.header.EventHeader) FromHeader(javax.sip.header.FromHeader) ProxyAuthenticateHeader(javax.sip.header.ProxyAuthenticateHeader) RecordRouteHeader(javax.sip.header.RecordRouteHeader) ViaHeader(javax.sip.header.ViaHeader) ReferToHeader(javax.sip.header.ReferToHeader) ToHeader(javax.sip.header.ToHeader) CallIdHeader(javax.sip.header.CallIdHeader) ReplacesHeader(gov.nist.javax.sip.header.extensions.ReplacesHeader) JoinHeader(gov.nist.javax.sip.header.extensions.JoinHeader)

Aggregations

JoinHeader (gov.nist.javax.sip.header.extensions.JoinHeader)1 ReplacesHeader (gov.nist.javax.sip.header.extensions.ReplacesHeader)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 ClientTransaction (javax.sip.ClientTransaction)1 InvalidArgumentException (javax.sip.InvalidArgumentException)1 SipException (javax.sip.SipException)1 TransactionDoesNotExistException (javax.sip.TransactionDoesNotExistException)1 TransactionUnavailableException (javax.sip.TransactionUnavailableException)1 SipURI (javax.sip.address.SipURI)1 AuthorizationHeader (javax.sip.header.AuthorizationHeader)1 CSeqHeader (javax.sip.header.CSeqHeader)1 CallIdHeader (javax.sip.header.CallIdHeader)1 ContactHeader (javax.sip.header.ContactHeader)1 ContentLengthHeader (javax.sip.header.ContentLengthHeader)1 ContentTypeHeader (javax.sip.header.ContentTypeHeader)1 EventHeader (javax.sip.header.EventHeader)1 ExpiresHeader (javax.sip.header.ExpiresHeader)1 ExtensionHeader (javax.sip.header.ExtensionHeader)1 FromHeader (javax.sip.header.FromHeader)1