public boolean sendUnidirectionalResponse ( RequestEvent request , int statusCode , String reasonPhrase , String toTag , Address contact , int expires ) { initErrorInfo ( ) ; if ( ( request == null ) || ( request . getRequest ( ) == null ) ) { setErrorMessage ( "Cannot send response, request information is null" ) ; setReturnCode ( INVALID_ARGUMENT ) ; return false ; } Response response ; try { response = parent . getMessageFactory ( ) . createResponse ( statusCode , request . getRequest ( ) ) ; if ( reasonPhrase != null ) { response . setReasonPhrase ( reasonPhrase ) ; } if ( toTag != null ) { ( ( ToHeader ) response . getHeader ( ToHeader . NAME ) ) . setTag ( toTag ) ; } if ( contact != null ) { response . addHeader ( parent . getHeaderFactory ( ) . createContactHeader ( contact ) ) ; } if ( expires != - 1 ) { response . addHeader ( parent . getHeaderFactory ( ) . createExpiresHeader ( expires ) ) ; } } catch ( Exception ex ) { setException ( ex ) ; setErrorMessage ( "Exception: " + ex . getClass ( ) . getName ( ) + ": " + ex . getMessage ( ) ) ; setReturnCode ( EXCEPTION_ENCOUNTERED ) ; return false ; } return sendUnidirectionalResponse ( response ) ; }
This method sends out a stateless response to the given request .