use of javax.sip.message.Response in project Openfire by igniterealtime.
the class SipManager method processResponse.
// -------------------- PROCESS RESPONSE
public void processResponse(ResponseEvent responseReceivedEvent) {
Log.debug("RESPONSE [" + responseReceivedEvent.getResponse().getStatusCode() + "]");
ClientTransaction clientTransaction = responseReceivedEvent.getClientTransaction();
if (clientTransaction == null) {
return;
}
Response response = responseReceivedEvent.getResponse();
String method = ((CSeqHeader) response.getHeader(CSeqHeader.NAME)).getMethod();
// OK
if (response.getStatusCode() == Response.OK) {
// REGISTER
if (method.equals(Request.REGISTER)) {
registerProcessing.processOK(clientTransaction, response);
}
} else // NOT_FOUND
if (response.getStatusCode() == Response.NOT_FOUND) {
if (method.equals(Request.REGISTER)) {
try {
unregister();
registrationFailed(RegistrationEvent.Type.NotFound);
} catch (CommunicationsException e) {
Log.error("NOT FOUND", e);
}
Log.debug("REGISTER NOT FOUND");
}
} else // NOT_IMPLEMENTED
if (response.getStatusCode() == Response.NOT_IMPLEMENTED) {
if (method.equals(Request.REGISTER)) {
// Fixed typo issues - Reported by pizarro
registerProcessing.processNotImplemented(clientTransaction, response);
}
} else // 401 UNAUTHORIZED
if (response.getStatusCode() == Response.UNAUTHORIZED || response.getStatusCode() == Response.PROXY_AUTHENTICATION_REQUIRED) {
if (method.equals(Request.REGISTER)) {
CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);
if (cseq.getSequenceNumber() < 2)
registerProcessing.processAuthenticationChallenge(clientTransaction, response);
else
registrationFailed(RegistrationEvent.Type.WrongPass);
}
} else // 403 Wrong Authorization user for this account
if (response.getStatusCode() == Response.FORBIDDEN) {
registrationFailed(RegistrationEvent.Type.Forbidden);
}
}
use of javax.sip.message.Response in project Openfire by igniterealtime.
the class SimpleSession method sendResponse.
public ServerTransaction sendResponse(int status, Request request, ServerTransaction serverTransaction) {
try {
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Starting response sending process.");
if (serverTransaction == null)
serverTransaction = udpSipProvider.getNewServerTransaction(request);
Response response = messageFactory.createResponse(status, request);
// Set "Exprires" header
if (request.getHeader(ExpiresHeader.NAME) != null)
response.setHeader(request.getHeader(ExpiresHeader.NAME));
// Add "Contact" header
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Preparing \"Contact\" header...");
try {
SipURI contactURI = addressFactory.createSipURI(null, InetAddress.getLocalHost().getHostAddress());
contactURI.setPort(sipPort);
Address contactAddress = addressFactory.createAddress(contactURI);
// contactAddress.setDisplayName(mySipUsername);
ContactHeader contactHeader = headerFactory.createContactHeader(contactAddress);
response.addHeader(contactHeader);
} catch (Exception e) {
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Exception occured when adding ContactHeader.", e);
// return false; // We can continue with this though.
}
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Sending response: " + response.toString());
serverTransaction.sendResponse(response);
// udpSipProvider.sendResponse(response);
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Response sent!");
return serverTransaction;
} catch (Exception ex) {
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: ", ex);
}
return null;
}
use of javax.sip.message.Response in project camel by apache.
the class SipPresenceAgentListener method processResponse.
public synchronized void processResponse(ResponseEvent responseReceivedEvent) {
Response response = responseReceivedEvent.getResponse();
Integer statusCode = response.getStatusCode();
if (SIP_MESSAGE_CODES.containsKey(statusCode)) {
LOG.debug(SIP_MESSAGE_CODES.get(statusCode) + " received from Subscriber");
}
}
use of javax.sip.message.Response in project camel by apache.
the class SipPresenceAgentListener method processPublish.
private void processPublish(RequestEvent requestEvent, ServerTransaction serverTransactionId) {
try {
Request request = requestEvent.getRequest();
LOG.debug("SipPresenceAgentListener: Received a Publish request, sending OK");
LOG.debug("SipPresenceAgentListener request: {}", request);
EventHeader eventHeader = (EventHeader) requestEvent.getRequest().getHeader(EventHeader.NAME);
Response response = sipPresenceAgent.getConfiguration().getMessageFactory().createResponse(202, request);
sipPresenceAgent.getProvider().sendResponse(response);
// Send notification to subscriber
sendNotification(eventHeader, false, request.getContent());
} catch (Exception e) {
LOG.error("Exception thrown during publish/notify processing in the Sip Presence Agent Listener", e);
}
}
use of javax.sip.message.Response in project camel by apache.
the class SipSubscriptionListener method processNotify.
public synchronized void processNotify(RequestEvent requestEvent, ServerTransaction serverTransactionId) {
LOG.debug("Notification received at Subscriber");
SipProvider provider = (SipProvider) requestEvent.getSource();
Request notify = requestEvent.getRequest();
try {
if (serverTransactionId == null) {
LOG.info("ServerTransaction is null. Creating new Server transaction");
serverTransactionId = provider.getNewServerTransaction(notify);
}
Dialog dialog = serverTransactionId.getDialog();
if (dialog != subscriberDialog) {
forkedDialog = dialog;
}
//Dispatch the response along the route
dispatchExchange(notify.getContent());
// Send back an success response
Response response = sipSubscriber.getConfiguration().getMessageFactory().createResponse(200, notify);
response.addHeader(sipSubscriber.getConfiguration().getContactHeader());
serverTransactionId.sendResponse(response);
SubscriptionStateHeader subscriptionState = (SubscriptionStateHeader) notify.getHeader(SubscriptionStateHeader.NAME);
// Subscription is terminated?
if (subscriptionState.getState().equalsIgnoreCase(SubscriptionStateHeader.TERMINATED)) {
LOG.info("Subscription state is terminated. Deleting the current dialog");
dialog.delete();
}
} catch (Exception e) {
LOG.error("Exception thrown during Notify processing in the SipSubscriptionListener.", e);
}
}
Aggregations