Search in sources :

Example 16 with Request

use of javax.sip.message.Request in project XobotOS by xamarin.

the class SipHelper method sendCancel.

public void sendCancel(ClientTransaction inviteTransaction) throws SipException {
    Request cancelRequest = inviteTransaction.createCancel();
    if (DEBUG)
        Log.d(TAG, "send CANCEL: " + cancelRequest);
    mSipProvider.getNewClientTransaction(cancelRequest).sendRequest();
}
Also used : Request(javax.sip.message.Request)

Example 17 with Request

use of javax.sip.message.Request in project XobotOS by xamarin.

the class SipHelper method sendRegister.

public ClientTransaction sendRegister(SipProfile userProfile, String tag, int expiry) throws SipException {
    try {
        Request request = createRequest(Request.REGISTER, userProfile, tag);
        if (expiry == 0) {
            // remove all previous registrations by wildcard
            // rfc3261#section-10.2.2
            request.addHeader(createWildcardContactHeader());
        } else {
            request.addHeader(createContactHeader(userProfile));
        }
        request.addHeader(mHeaderFactory.createExpiresHeader(expiry));
        ClientTransaction clientTransaction = mSipProvider.getNewClientTransaction(request);
        clientTransaction.sendRequest();
        return clientTransaction;
    } catch (ParseException e) {
        throw new SipException("sendRegister()", e);
    }
}
Also used : ClientTransaction(javax.sip.ClientTransaction) Request(javax.sip.message.Request) ParseException(java.text.ParseException) SipException(javax.sip.SipException)

Example 18 with Request

use of javax.sip.message.Request in project XobotOS by xamarin.

the class SipHelper method sendInvite.

public ClientTransaction sendInvite(SipProfile caller, SipProfile callee, String sessionDescription, String tag, ReferredByHeader referredBy, String replaces) throws SipException {
    try {
        Request request = createRequest(Request.INVITE, caller, callee, tag);
        if (referredBy != null)
            request.addHeader(referredBy);
        if (replaces != null) {
            request.addHeader(mHeaderFactory.createHeader(ReplacesHeader.NAME, replaces));
        }
        request.setContent(sessionDescription, mHeaderFactory.createContentTypeHeader("application", "sdp"));
        ClientTransaction clientTransaction = mSipProvider.getNewClientTransaction(request);
        if (DEBUG)
            Log.d(TAG, "send INVITE: " + request);
        clientTransaction.sendRequest();
        return clientTransaction;
    } catch (ParseException e) {
        throw new SipException("sendInvite()", e);
    }
}
Also used : ClientTransaction(javax.sip.ClientTransaction) Request(javax.sip.message.Request) ParseException(java.text.ParseException) SipException(javax.sip.SipException)

Example 19 with Request

use of javax.sip.message.Request in project XobotOS by xamarin.

the class SIPDialog method createPrack.

/*
     * (non-Javadoc) Retransmissions of the reliable provisional response cease when a matching
     * PRACK is received by the UA core. PRACK is like any other request within a dialog, and the
     * UAS core processes it according to the procedures of Sections 8.2 and 12.2.2 of RFC 3261. A
     * matching PRACK is defined as one within the same dialog as the response, and whose method,
     * CSeq-num, and response-num in the RAck header field match, respectively, the method from
     * the CSeq, the sequence number from the CSeq, and the sequence number from the RSeq of the
     * reliable provisional response.
     * 
     * @see javax.sip.Dialog#createPrack(javax.sip.message.Response)
     */
public Request createPrack(Response relResponse) throws DialogDoesNotExistException, SipException {
    if (this.getState() == null || this.getState().equals(DialogState.TERMINATED))
        throw new DialogDoesNotExistException("Dialog not initialized or terminated");
    if ((RSeq) relResponse.getHeader(RSeqHeader.NAME) == null) {
        throw new SipException("Missing RSeq Header");
    }
    try {
        SIPResponse sipResponse = (SIPResponse) relResponse;
        SIPRequest sipRequest = (SIPRequest) this.createRequest(Request.PRACK, (SIPResponse) relResponse);
        String toHeaderTag = sipResponse.getTo().getTag();
        sipRequest.setToTag(toHeaderTag);
        RAck rack = new RAck();
        RSeq rseq = (RSeq) relResponse.getHeader(RSeqHeader.NAME);
        rack.setMethod(sipResponse.getCSeq().getMethod());
        rack.setCSequenceNumber((int) sipResponse.getCSeq().getSeqNumber());
        rack.setRSequenceNumber(rseq.getSeqNumber());
        sipRequest.setHeader(rack);
        return (Request) sipRequest;
    } catch (Exception ex) {
        InternalErrorHandler.handleException(ex);
        return null;
    }
}
Also used : SIPResponse(gov.nist.javax.sip.message.SIPResponse) RAck(gov.nist.javax.sip.header.RAck) Request(javax.sip.message.Request) SIPRequest(gov.nist.javax.sip.message.SIPRequest) DialogDoesNotExistException(javax.sip.DialogDoesNotExistException) RSeq(gov.nist.javax.sip.header.RSeq) SipException(javax.sip.SipException) SIPRequest(gov.nist.javax.sip.message.SIPRequest) DialogDoesNotExistException(javax.sip.DialogDoesNotExistException) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) ObjectInUseException(javax.sip.ObjectInUseException) SipException(javax.sip.SipException) IOException(java.io.IOException) TransactionDoesNotExistException(javax.sip.TransactionDoesNotExistException)

Example 20 with Request

use of javax.sip.message.Request in project Openfire by igniterealtime.

the class RegisterProcessing method unregister.

/**
     * Synchronize because of timer tasks
     *
     * @throws CommunicationsException
     */
synchronized void unregister() throws CommunicationsException {
    try {
        Log.debug("UNREGISTER");
        cancelPendingRegistrations();
        isRegistered = false;
        isUnregistering = true;
        Request registerRequest = getRegisterRequest();
        if (this.registerRequest == null) {
            throw new CommunicationsException("Couldn't find the initial register request");
        }
        Request unregisterRequest = (Request) registerRequest.clone();
        try {
            unregisterRequest.getExpires().setExpires(0);
            CSeqHeader cSeqHeader = (CSeqHeader) unregisterRequest.getHeader(CSeqHeader.NAME);
            // [issue 1] - increment registration cseq number
            // reported by - Roberto Tealdi <roby.tea@tin.it>
            cSeqHeader.setSequenceNumber(cSeqHeader.getSequenceNumber() + 1);
        } catch (InvalidArgumentException ex) {
            // Shouldn't happen
            throw new CommunicationsException("Unable to set Expires Header", ex);
        }
        ClientTransaction unregisterTransaction = null;
        try {
            unregisterTransaction = sipManCallback.sipProvider.getNewClientTransaction(unregisterRequest);
        } catch (TransactionUnavailableException ex) {
            throw new CommunicationsException("Unable to create a unregister transaction", ex);
        }
        try {
            sipManCallback.fireUnregistering(sipManCallback.currentlyUsedURI);
            unregisterTransaction.sendRequest();
        } catch (SipException ex) {
            throw new CommunicationsException("Failed to send unregister request", ex);
        }
    } catch (Exception e) {
        Log.error("unregister", e);
    }
}
Also used : Request(javax.sip.message.Request) CommunicationsException(org.jivesoftware.openfire.sip.tester.comm.CommunicationsException) SipSecurityException(org.jivesoftware.openfire.sip.tester.security.SipSecurityException) CommunicationsException(org.jivesoftware.openfire.sip.tester.comm.CommunicationsException) ParseException(java.text.ParseException)

Aggregations

Request (javax.sip.message.Request)38 ParseException (java.text.ParseException)21 SipException (javax.sip.SipException)21 InvalidArgumentException (javax.sip.InvalidArgumentException)13 ClientTransaction (javax.sip.ClientTransaction)9 SipURI (javax.sip.address.SipURI)9 Response (javax.sip.message.Response)9 NotFoundException (org.jivesoftware.util.NotFoundException)7 TooManyListenersException (java.util.TooManyListenersException)6 ServerTransaction (javax.sip.ServerTransaction)6 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)6 Address (javax.sip.address.Address)5 CSeqHeader (javax.sip.header.CSeqHeader)5 ViaHeader (javax.sip.header.ViaHeader)5 SIPRequest (gov.nist.javax.sip.message.SIPRequest)4 FromHeader (javax.sip.header.FromHeader)4 SubscriptionStateHeader (javax.sip.header.SubscriptionStateHeader)4 ToHeader (javax.sip.header.ToHeader)4 SIPClientTransaction (gov.nist.javax.sip.stack.SIPClientTransaction)3 IOException (java.io.IOException)3