// Both 2xx response to SUBSCRIBE and NOTIFY need a Contact
Address address = addressFactory.createAddress("Notifier <sip:127.0.0.1>");
((SipURI) address.getURI()).setPort(udpProvider.getListeningPoint("udp")
.getPort());
ContactHeader contactHeader = headerFactory.createContactHeader(address);
response.addHeader(contactHeader);
// Expires header is mandatory in 2xx responses to SUBSCRIBE
ExpiresHeader expires = (ExpiresHeader) request.getHeader(ExpiresHeader.NAME);
if (expires == null) {
expires = headerFactory.createExpiresHeader(30); // rather short
}
response.addHeader(expires);
/*
* NOTIFY requests MUST contain a "Subscription-State" header with a value of
* "active", "pending", or "terminated". The "active" value indicates that the
* subscription has been accepted and has been authorized (in most cases; see
* section 5.2.). The "pending" value indicates that the subscription has been
* received, but that policy information is insufficient to accept or deny the
* subscription at this time. The "terminated" value indicates that the
* subscription is not active.
*/
Address fromAddress = ((ToHeader) response.getHeader(ToHeader.NAME)).getAddress();
String fromTag = ((ToHeader) response.getHeader(ToHeader.NAME)).getTag();
FromHeader fromHeader = headerFactory.createFromHeader(fromAddress, fromTag);
Address toAddress = ((FromHeader) response.getHeader(FromHeader.NAME)).getAddress();
String toTag = ((FromHeader) response.getHeader(FromHeader.NAME)).getTag();
ToHeader toHeader = headerFactory.createToHeader(toAddress, toTag);
CallIdHeader callId = (CallIdHeader) response.getHeader(CallIdHeader.NAME);
ContactHeader requestContact = (ContactHeader) request
.getHeader(ContactHeader.NAME);
SipURI notifyRuri = (SipURI) requestContact.getAddress().getURI();
CSeqHeader cSeq = headerFactory.createCSeqHeader(1L, Request.NOTIFY);
String ipAddress = sipProvider.getListeningPoint("udp").getIPAddress();
int port = sipProvider.getListeningPoint("udp").getPort();
ViaHeader viaHeader = headerFactory.createViaHeader(ipAddress, port, "udp", null);
LinkedList llist = new LinkedList<ViaHeader>();