System.err.println(e.getMessage());
}
}
private static Request createMessage(String from, String to, long id){
Request request = null;
id += 1;//0 not allowed
//Invite
try {
// create From Header
SipURI fromAddress = addressFactory.createSipURI(from, "send.com");
Address fromNameAddress = addressFactory.createAddress(fromAddress);
fromNameAddress.setDisplayName(from);
FromHeader fromHeader = headerFactory.createFromHeader(fromNameAddress,"12345");
// create To Header
SipURI toAddress = addressFactory.createSipURI(to, "empf.com");
Address toNameAddress = addressFactory.createAddress(toAddress);
toNameAddress.setDisplayName(to);
ToHeader toHeader = headerFactory.createToHeader(toNameAddress, null);
// create Request URI
SipURI requestURI = addressFactory.createSipURI(from, "127.0.0.1:5080");
// Create ViaHeaders
ArrayList viaHeaders = new ArrayList();
ViaHeader viaHeader = headerFactory.createViaHeader("127.0.0.1",
sipProvider.getListeningPoint(transport).getPort(), transport, null);
viaHeaders.add(viaHeader);
// Create a new CallId header
CallIdHeader callIdHeader = sipProvider.getNewCallId();
//callIdHeader.setCallId("1");
// Create a new Cseq header
CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(id, Request.INVITE);
// Create a new MaxForwardsHeader
MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(70);
// Create the request.
request = messageFactory.createRequest(requestURI,Request.INVITE,
callIdHeader, cSeqHeader, fromHeader, toHeader, viaHeaders, maxForwards);
// Create contact headers
String host = "127.0.0.1";
SipURI contactUrl = addressFactory.createSipURI(from, host);
contactUrl.setPort(listeningPoint.getPort());
// Create the contact name address.
SipURI contactURI = addressFactory.createSipURI(from, host);
contactURI.setPort(sipProvider.getListeningPoint(transport).getPort());
contactURI.setTransportParam(transport);
Address contactAddress = addressFactory.createAddress(contactURI);
// Add the contact address.
contactAddress.setDisplayName(from);
contactHeader = headerFactory.createContactHeader(contactAddress);
request.addHeader(contactHeader);
} catch (ParseException e) {
e.printStackTrace();
System.err.println(e.getMessage());
} catch (InvalidArgumentException e){