sipStack.getLogWriter().logWarning(
"Dialog exists -- you may want to use Dialog.sendAck() "
+ dialog.getState());
}
}
Hop hop = sipStack.getRouter((SIPRequest) request).getNextHop(request);
if (hop == null)
throw new SipException("could not determine next hop!");
SIPRequest sipRequest = (SIPRequest) request;
// Check if we have a valid via.
// Null request is used to send default proxy keepalive messages.
if ((!sipRequest.isNullRequest()) && sipRequest.getTopmostVia() == null)
throw new SipException("Invalid SipRequest -- no via header!");
try {
/*
* JvB: Via branch should already be OK, dont touch it here? Some
* apps forward statelessly, and then it's not set. So set only when
* not set already, dont overwrite CANCEL branch here..
*/
if (!sipRequest.isNullRequest()) {
Via via = sipRequest.getTopmostVia();
String branch = via.getBranch();
if (branch == null || branch.length() == 0) {
via.setBranch(sipRequest.getTransactionId());
}
}
MessageChannel messageChannel = null;
if (this.listeningPoints.containsKey(hop.getTransport()
.toUpperCase()))
messageChannel = sipStack.createRawMessageChannel(
this.getListeningPoint(hop.getTransport()).getIPAddress(),
this.getListeningPoint(hop.getTransport()).getPort(), hop);
if (messageChannel != null) {
messageChannel.sendMessage((SIPMessage) sipRequest,hop);
} else {
throw new SipException(
"Could not create a message channel for "
+ hop.toString());
}
} catch (IOException ex) {
if (sipStack.isLoggingEnabled()) {
sipStack.getLogWriter().logException(ex);
}