* @throws SipException
* @throws InvalidArgumentException
*/
public void processRefer(RequestEvent requestEvent,
ServerTransaction serverTransaction) throws ParseException, SipException, InvalidArgumentException {
SipProvider sipProvider = (SipProvider) requestEvent.getSource();
Request refer = requestEvent.getRequest();
logger.info("referee: got an REFER sending Accepted");
logger.info("referee: " + refer.getMethod() );
dialog = requestEvent.getDialog();
logger.info("referee : dialog = " + requestEvent.getDialog());
// Check that it has a Refer-To, if not bad request
ReferToHeader refTo = (ReferToHeader) refer.getHeader( ReferToHeader.NAME );
if (refTo==null) {
Response bad = messageFactory.createResponse(Response.BAD_REQUEST, refer);
bad.setReasonPhrase( "Missing Refer-To" );
sipProvider.sendResponse( bad );
TestHarness.fail("Bad REFER request. Missing Refer-To.");
}
// New test: first time, only send 100 Trying, to test that retransmission
// continues for non-INVITE requests (using UDP)
// before(!) creating a ServerTransaction! Else retransmissions are filtered
if (!tryingSent && "udp".equalsIgnoreCase(transport)) {
tryingSent = true;
sipProvider.sendResponse( messageFactory.createResponse(100, refer) );
return;
}
// Always create a ServerTransaction, best as early as possible in the code
Response response = null;
ServerTransaction st = requestEvent.getServerTransaction();
if (st == null) {
st = sipProvider.getNewServerTransaction(refer);
}
// Check if it is an initial SUBSCRIBE or a refresh / unsubscribe
String toTag = Integer.toHexString( (int) (Math.random() * Integer.MAX_VALUE) );
response = messageFactory.createResponse(202, refer);