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);
}
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());
}
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;
}
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;
}
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);
}
Aggregations