Search in sources :

Example 1 with RequestEventExt

use of gov.nist.javax.sip.RequestEventExt in project jain-sip.ha by RestComm.

the class SimpleStatefulProxy method processBye.

public void processBye(RequestEvent requestEvent) {
    try {
        serverTransaction = requestEvent.getServerTransaction();
        if (serverTransaction == null) {
            try {
                serverTransaction = sipProvider.getNewServerTransaction(requestEvent.getRequest());
            } catch (Exception e) {
                ((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
                return;
            }
        }
        int remotePort = ((RequestEventExt) requestEvent).getRemotePort();
        if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
            remotePort = ((MessageExt) requestEvent.getRequest()).getTopmostViaHeader().getPort();
        }
        ((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
        final Request request = (Request) requestEvent.getRequest().clone();
        ((SipURI) request.getRequestURI()).setPort(5070);
        request.removeLast(RouteHeader.NAME);
        RouteHeader routeHeader = (RouteHeader) request.getHeader(RouteHeader.NAME);
        if (routeHeader != null && (((SipURI) routeHeader.getAddress().getURI()).getPort() == 5080 || ((SipURI) routeHeader.getAddress().getURI()).getPort() == 5081)) {
            request.removeFirst(RouteHeader.NAME);
        }
        request.addHeader(headerFactory.createViaHeader(ipAddress, myPort, transport, null));
        final ClientTransaction ct = sipProvider.getNewClientTransaction(request);
        ct.sendRequest();
    } catch (Exception e) {
        ((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
    }
}
Also used : RequestEventExt(gov.nist.javax.sip.RequestEventExt) MessageExt(gov.nist.javax.sip.message.MessageExt) RouteHeader(javax.sip.header.RouteHeader) RecordRouteHeader(javax.sip.header.RecordRouteHeader) ClientTransaction(javax.sip.ClientTransaction) Request(javax.sip.message.Request) SIPRequest(gov.nist.javax.sip.message.SIPRequest) SipURI(javax.sip.address.SipURI) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) CacheException(org.jboss.cache.CacheException) SipException(javax.sip.SipException) ListeningPoint(javax.sip.ListeningPoint)

Example 2 with RequestEventExt

use of gov.nist.javax.sip.RequestEventExt in project jain-sip.ha by RestComm.

the class SimpleB2BUAHandler method processAck.

public void processAck(RequestEvent requestEvent) {
    int remotePort = ((RequestEventExt) requestEvent).getRemotePort();
    if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
        remotePort = ((MessageExt) requestEvent.getRequest()).getTopmostViaHeader().getPort();
    }
    ((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
    try {
        if (!sendAckOn2xx) {
            Dialog dialog = null;
            if (remotePort == 5070) {
                dialog = getIncomingDialog();
            }
            if (remotePort == 5050 || remotePort == 5060 || remotePort == 5065) {
                storeIncomingDialogId(requestEvent.getDialog().getDialogId());
                dialog = getOutgoingDialog();
            }
            final Request ack = dialog.createAck(((MessageExt) requestEvent.getRequest()).getCSeqHeader().getSeqNumber());
            dialog.sendAck(ack);
        } else {
            if (myPort == 5080 && getIncomingDialogId() == null) {
                storeIncomingDialogId(requestEvent.getDialog().getDialogId());
            }
            if (remotePort == 5050 || remotePort == 5060 || remotePort == 5065) {
                storeIncomingDialogId(requestEvent.getDialog().getDialogId());
            }
        }
        if (createInviteOnAck) {
            createInviteOnAck = false;
            Request request = getIncomingDialog().createRequest("INVITE");
            final ClientTransaction ct = sipProvider.getNewClientTransaction(request);
            getIncomingDialog().sendRequest(ct);
        }
    } catch (Exception e) {
        ((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
    }
}
Also used : RequestEventExt(gov.nist.javax.sip.RequestEventExt) MessageExt(gov.nist.javax.sip.message.MessageExt) Dialog(javax.sip.Dialog) ClientTransaction(javax.sip.ClientTransaction) Request(javax.sip.message.Request) SIPRequest(gov.nist.javax.sip.message.SIPRequest) ListeningPoint(javax.sip.ListeningPoint) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) CacheException(org.jboss.cache.CacheException) SipException(javax.sip.SipException)

Example 3 with RequestEventExt

use of gov.nist.javax.sip.RequestEventExt in project jain-sip.ha by RestComm.

the class SimpleB2BUAHandler method processBye.

public void processBye(RequestEvent requestEvent) {
    try {
        int remotePort = ((RequestEventExt) requestEvent).getRemotePort();
        if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
            remotePort = ((MessageExt) requestEvent.getRequest()).getTopmostViaHeader().getPort();
        }
        ((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
        requestEvent.getServerTransaction().sendResponse(messageFactory.createResponse(200, requestEvent.getRequest()));
        Dialog dialog = getOutgoingDialog();
        if (remotePort == 5060 || remotePort == 5065) {
            dialog = getIncomingDialog();
        }
        Request request = dialog.createRequest(Request.BYE);
        final ClientTransaction ct = sipProvider.getNewClientTransaction(request);
        dialog.sendRequest(ct);
    } catch (Exception e) {
        ((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
    }
}
Also used : RequestEventExt(gov.nist.javax.sip.RequestEventExt) MessageExt(gov.nist.javax.sip.message.MessageExt) Dialog(javax.sip.Dialog) ClientTransaction(javax.sip.ClientTransaction) Request(javax.sip.message.Request) SIPRequest(gov.nist.javax.sip.message.SIPRequest) ListeningPoint(javax.sip.ListeningPoint) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) CacheException(org.jboss.cache.CacheException) SipException(javax.sip.SipException)

Example 4 with RequestEventExt

use of gov.nist.javax.sip.RequestEventExt in project jain-sip.ha by RestComm.

the class SimpleStatefulProxy method processAck.

public void processAck(RequestEvent requestEvent) {
    int remotePort = ((RequestEventExt) requestEvent).getRemotePort();
    if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
        remotePort = ((MessageExt) requestEvent.getRequest()).getTopmostViaHeader().getPort();
    }
    ((ClusteredSipStack) sipStack).getStackLogger().logDebug("remotePort = " + remotePort);
    try {
        final Request ack = (Request) requestEvent.getRequest().clone();
        String branchId = getClientTransactionId();
        ack.addHeader(headerFactory.createViaHeader(ipAddress, myPort, transport, branchId));
        ((SipURI) ack.getRequestURI()).setPort(getClientTransactionPort());
        ack.removeLast(RouteHeader.NAME);
        RouteHeader routeHeader = (RouteHeader) ack.getHeader(RouteHeader.NAME);
        if (routeHeader != null && (((SipURI) routeHeader.getAddress().getURI()).getPort() == 5080 || ((SipURI) routeHeader.getAddress().getURI()).getPort() == 5081)) {
            ack.removeFirst(RouteHeader.NAME);
        }
        sipProvider.sendRequest(ack);
    } catch (Exception e) {
        ((SipStackImpl) sipStack).getStackLogger().logError("unexpected exception", e);
    }
}
Also used : RequestEventExt(gov.nist.javax.sip.RequestEventExt) MessageExt(gov.nist.javax.sip.message.MessageExt) RouteHeader(javax.sip.header.RouteHeader) RecordRouteHeader(javax.sip.header.RecordRouteHeader) Request(javax.sip.message.Request) SIPRequest(gov.nist.javax.sip.message.SIPRequest) SipURI(javax.sip.address.SipURI) ListeningPoint(javax.sip.ListeningPoint) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) CacheException(org.jboss.cache.CacheException) SipException(javax.sip.SipException)

Aggregations

RequestEventExt (gov.nist.javax.sip.RequestEventExt)4 MessageExt (gov.nist.javax.sip.message.MessageExt)4 SIPRequest (gov.nist.javax.sip.message.SIPRequest)4 ParseException (java.text.ParseException)4 InvalidArgumentException (javax.sip.InvalidArgumentException)4 ListeningPoint (javax.sip.ListeningPoint)4 SipException (javax.sip.SipException)4 Request (javax.sip.message.Request)4 CacheException (org.jboss.cache.CacheException)4 ClientTransaction (javax.sip.ClientTransaction)3 Dialog (javax.sip.Dialog)2 SipURI (javax.sip.address.SipURI)2 RecordRouteHeader (javax.sip.header.RecordRouteHeader)2 RouteHeader (javax.sip.header.RouteHeader)2