use of gov.nist.javax.sip.header.RecordRouteList in project XobotOS by xamarin.
the class SIPResponse method createRequest.
/**
* Generate a request from a response.
*
* @param requestURI -- the request URI to assign to the request.
* @param via -- the Via header to assign to the request
* @param cseq -- the CSeq header to assign to the request
* @param from -- the From header to assign to the request
* @param to -- the To header to assign to the request
* @return -- the newly generated sip request.
*/
public SIPRequest createRequest(SipUri requestURI, Via via, CSeq cseq, From from, To to) {
SIPRequest newRequest = new SIPRequest();
String method = cseq.getMethod();
newRequest.setMethod(method);
newRequest.setRequestURI(requestURI);
this.setBranch(via, method);
newRequest.setHeader(via);
newRequest.setHeader(cseq);
Iterator headerIterator = getHeaders();
while (headerIterator.hasNext()) {
SIPHeader nextHeader = (SIPHeader) headerIterator.next();
// Some headers do not belong in a Request ....
if (SIPMessage.isResponseHeader(nextHeader) || nextHeader instanceof ViaList || nextHeader instanceof CSeq || nextHeader instanceof ContentType || nextHeader instanceof ContentLength || nextHeader instanceof RecordRouteList || nextHeader instanceof RequireList || // JvB: added
nextHeader instanceof ContactList || nextHeader instanceof ContentLength || nextHeader instanceof ServerHeader || nextHeader instanceof ReasonHeader || nextHeader instanceof SessionExpires || nextHeader instanceof ReasonList) {
continue;
}
if (nextHeader instanceof To)
nextHeader = (SIPHeader) to;
else if (nextHeader instanceof From)
nextHeader = (SIPHeader) from;
try {
newRequest.attachHeader(nextHeader, false);
} catch (SIPDuplicateHeaderException e) {
//Should not happen!
e.printStackTrace();
}
}
try {
// JvB: all requests need a Max-Forwards
newRequest.attachHeader(new MaxForwards(70), false);
} catch (Exception d) {
}
if (MessageFactoryImpl.getDefaultUserAgentHeader() != null) {
newRequest.setHeader(MessageFactoryImpl.getDefaultUserAgentHeader());
}
return newRequest;
}
use of gov.nist.javax.sip.header.RecordRouteList in project XobotOS by xamarin.
the class RecordRouteParser method parse.
/**
* parse the String message and generate the RecordRoute List Object
* @return SIPHeader the RecordRoute List object
* @throws ParseException if errors occur during the parsing
*/
public SIPHeader parse() throws ParseException {
RecordRouteList recordRouteList = new RecordRouteList();
if (debug)
dbg_enter("RecordRouteParser.parse");
try {
this.lexer.match(TokenTypes.RECORD_ROUTE);
this.lexer.SPorHT();
this.lexer.match(':');
this.lexer.SPorHT();
while (true) {
RecordRoute recordRoute = new RecordRoute();
super.parse(recordRoute);
recordRouteList.add(recordRoute);
this.lexer.SPorHT();
char la = lexer.lookAhead(0);
if (la == ',') {
this.lexer.match(',');
this.lexer.SPorHT();
} else if (la == '\n')
break;
else
throw createParseException("unexpected char");
}
return recordRouteList;
} finally {
if (debug)
dbg_leave("RecordRouteParser.parse");
}
}
Aggregations