Search in sources :

Example 16 with Address

use of javax.sip.address.Address in project camel by apache.

the class SipConfiguration method createContactHeader.

private void createContactHeader() throws ParseException {
    SipURI contactURI = addressFactory.createSipURI(getFromUser(), getFromHost());
    contactURI.setTransportParam(getTransport());
    contactURI.setPort(Integer.valueOf(getFromPort()).intValue());
    Address contactAddress = addressFactory.createAddress(contactURI);
    // Add the contact address.
    contactAddress.setDisplayName(getFromUser());
    contactHeader = headerFactory.createContactHeader(contactAddress);
}
Also used : Address(javax.sip.address.Address) SipURI(javax.sip.address.SipURI)

Example 17 with Address

use of javax.sip.address.Address in project Openfire by igniterealtime.

the class RegisterProcessing method processNotImplemented.

void processNotImplemented(ClientTransaction transatcion, Response response) {
    isRegistered = true;
    FromHeader fromHeader = ((FromHeader) response.getHeader(FromHeader.NAME));
    Address address = fromHeader.getAddress();
    sipManCallback.fireUnregistered("Server returned NOT_IMPLEMENTED. " + address.toString());
}
Also used : Address(javax.sip.address.Address)

Example 18 with Address

use of javax.sip.address.Address in project Openfire by igniterealtime.

the class SipManager method getContactHeader.

/**
     * Initialises SipManager's contactHeader field in accordance with
     * javax.sip.IP_ADDRESS net.java.mais.sip.DISPLAY_NAME
     * net.java.mais.sip.TRANSPORT net.java.mais.sip.PREFERRED_LOCAL_PORT and
     * returns a reference to it.
     *
     * @param useLocalHostAddress specifies whether the SipURI in the contact header should
     *                            contain the value of javax.sip.IP_ADDRESS (true) or that of
     *                            net.java.mais.sip.PUBLIC_ADDRESS (false).
     * @return a reference to SipManager's contactHeader field.
     * @throws CommunicationsException if a ParseException occurs while initially composing the
     *                                 FromHeader.
     */
public ContactHeader getContactHeader(boolean useLocalHostAddress) throws CommunicationsException {
    if (contactHeader != null) {
        return contactHeader;
    }
    try {
        SipURI contactURI;
        if (useLocalHostAddress) {
            contactURI = addressFactory.createSipURI(null, UserCredentials.getUserDisplay() + "@" + publicIpAddress.getAddress().getHostAddress());
        } else {
            contactURI = (SipURI) addressFactory.createURI(currentlyUsedURI);
        }
        contactURI.setPort(publicIpAddress.getPort());
        Address contactAddress = addressFactory.createAddress(contactURI);
        if (displayName != null && displayName.trim().length() > 0) {
            contactAddress.setDisplayName(displayName);
        }
        contactHeader = headerFactory.createContactHeader(contactAddress);
    } catch (ParseException ex) {
        throw new CommunicationsException("A ParseException occurred while creating From Header!", ex);
    }
    return contactHeader;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) Address(javax.sip.address.Address) ParseException(java.text.ParseException) SipURI(javax.sip.address.SipURI) CommunicationsException(org.jivesoftware.openfire.sip.tester.comm.CommunicationsException)

Example 19 with Address

use of javax.sip.address.Address in project Openfire by igniterealtime.

the class SimpleSession method prepareNotifyRequest.

private Request prepareNotifyRequest(Dialog dialog) throws ParseException {
    if (dialog == null) {
        return null;
    }
    printDialog(dialog);
    String fromTag = dialog.getRemoteTag();
    Address fromAddress = dialog.getRemoteParty();
    SipURI destUri = (SipURI) fromAddress.getURI();
    dialog.incrementLocalSequenceNumber();
    long seqNum = dialog.getLocalSeqNumber();
    String callId = dialog.getCallId().getCallId();
    SipURI fromReqUri = null;
    Log.debug("Getting request URI from dialog");
    Address fromReqAddr = dialog.getRemoteTarget();
    if (fromReqAddr != null && fromReqAddr.getURI() != null && fromReqAddr.getURI() instanceof SipURI)
        fromReqUri = (SipURI) fromReqAddr.getURI();
    if (fromReqUri == null) {
        Log.debug("Getting request URI from destination URI");
        fromReqUri = destUri;
    }
    // Instantiate request packet
    Request notifyRequest = prepareRequest(RequestType.NOTIFY, destUri, fromTag, fromReqUri, callId, seqNum);
    //		Request notifyRequest = dialog.createRequest(Request.NOTIFY);
    ((FromHeader) notifyRequest.getHeader(FromHeader.NAME)).setTag(dialog.getLocalTag());
    // Set "subscription state" header
    SubscriptionStateHeader subscriptionStateHeader = headerFactory.createSubscriptionStateHeader(SubscriptionStateHeader.ACTIVE.toLowerCase());
    //		if (expires > 0) subscriptionStateHeader.setExpires(expires);
    notifyRequest.setHeader(subscriptionStateHeader);
    // Set "event" header
    notifyRequest.setHeader(headerFactory.createEventHeader("presence"));
    return notifyRequest;
}
Also used : InetAddress(java.net.InetAddress) Address(javax.sip.address.Address) FromHeader(javax.sip.header.FromHeader) SubscriptionStateHeader(javax.sip.header.SubscriptionStateHeader) Request(javax.sip.message.Request) SipURI(javax.sip.address.SipURI)

Example 20 with Address

use of javax.sip.address.Address in project XobotOS by xamarin.

the class SipHelper method createContactHeader.

private ContactHeader createContactHeader(SipProfile profile, String ip, int port) throws ParseException, SipException {
    SipURI contactURI = (ip == null) ? createSipUri(profile.getUserName(), profile.getProtocol(), getListeningPoint()) : createSipUri(profile.getUserName(), profile.getProtocol(), ip, port);
    Address contactAddress = mAddressFactory.createAddress(contactURI);
    contactAddress.setDisplayName(profile.getDisplayName());
    return mHeaderFactory.createContactHeader(contactAddress);
}
Also used : Address(javax.sip.address.Address) SipURI(javax.sip.address.SipURI)

Aggregations

Address (javax.sip.address.Address)24 SipURI (javax.sip.address.SipURI)22 Request (javax.sip.message.Request)12 ParseException (java.text.ParseException)11 ContactHeader (javax.sip.header.ContactHeader)9 FromHeader (javax.sip.header.FromHeader)9 SipException (javax.sip.SipException)8 ToHeader (javax.sip.header.ToHeader)8 ViaHeader (javax.sip.header.ViaHeader)8 InvalidArgumentException (javax.sip.InvalidArgumentException)7 CSeqHeader (javax.sip.header.CSeqHeader)7 CallIdHeader (javax.sip.header.CallIdHeader)7 MaxForwardsHeader (javax.sip.header.MaxForwardsHeader)7 SubscriptionStateHeader (javax.sip.header.SubscriptionStateHeader)7 InetAddress (java.net.InetAddress)6 ArrayList (java.util.ArrayList)6 ContentTypeHeader (javax.sip.header.ContentTypeHeader)6 Header (javax.sip.header.Header)6 EventHeader (javax.sip.header.EventHeader)5 ExpiresHeader (javax.sip.header.ExpiresHeader)5