Exemple #1
0
/** Constructor.
 */
func NewSIPResponse() *SIPResponse {
	this := &SIPResponse{}
	this.SIPMessage.super()
	return this
}

func (this *SIPResponse) GetReasonPhraseFromInt(rc int) string {
	var retval string
	switch rc {
	case TRYING:
		retval = "Trying"

	case RINGING:
		retval = "Ringing"

	case CALL_IS_BEING_FORWARDED:
		retval = "Call is being forwarded"

	case QUEUED:
		retval = "Queued"

	case SESSION_PROGRESS:
		retval = "Session progress"

	case OK:
		retval = "OK"

	case ACCEPTED:
		retval = "Accepted"

	case MULTIPLE_CHOICES:
		retval = "Multiple choices"

	case MOVED_PERMANENTLY:
		retval = "Moved permanently"

	case MOVED_TEMPORARILY:
		retval = "Moved Temporarily"

	case USE_PROXY:
		retval = "Use proxy"

	case ALTERNATIVE_SERVICE:
		retval = "Alternative service"

	case BAD_REQUEST:
		retval = "Bad request"

	case UNAUTHORIZED:
		retval = "Unauthorized"

	case PAYMENT_REQUIRED:
		retval = "Payment required"

	case FORBIDDEN:
		retval = "Forbidden"

	case NOT_FOUND:
		retval = "Not found"

	case METHOD_NOT_ALLOWED:
		retval = "Method not allowed"

	case NOT_ACCEPTABLE:
		retval = "Not acceptable"

	case PROXY_AUTHENTICATION_REQUIRED:
		retval = "Proxy Authentication required"

	case REQUEST_TIMEOUT:
		retval = "Request timeout"

	case GONE:
		retval = "Gone"

	case TEMPORARILY_UNAVAILABLE:
		retval = "Temporarily Unavailable"

	case REQUEST_ENTITY_TOO_LARGE:
		retval = "Request entity too large"

	case REQUEST_URI_TOO_LONG:
		retval = "Request-URI too large"

	case UNSUPPORTED_MEDIA_TYPE:
		retval = "Unsupported media type"

	case UNSUPPORTED_URI_SCHEME:
		retval = "Unsupported URI Scheme"

	case BAD_EXTENSION:
		retval = "Bad extension"

	case EXTENSION_REQUIRED:
		retval = "Etension Required"

	case INTERVAL_TOO_BRIEF:
		retval = "Interval too brief"

	case CALL_OR_TRANSACTION_DOES_NOT_EXIST:
		retval = "Call leg/Transaction does not exist"

	case LOOP_DETECTED:
		retval = "Loop detected"

	case TOO_MANY_HOPS:
		retval = "Too many hops"

	case ADDRESS_INCOMPLETE:
		retval = "Address incomplete"

	case AMBIGUOUS:
		retval = "Ambiguous"

	case BUSY_HERE:
		retval = "Busy here"

	case REQUEST_TERMINATED:
		retval = "Request Terminated"

	case NOT_ACCEPTABLE_HERE:
		retval = "Not Accpetable here"

	case BAD_EVENT:
		retval = "Bad Event"

	case REQUEST_PENDING:
		retval = "Request Pending"

	case SERVER_INTERNAL_ERROR:
		retval = "Server Internal Error"

	case UNDECIPHERABLE:
		retval = "Undecipherable"

	case NOT_IMPLEMENTED:
		retval = "Not implemented"

	case BAD_GATEWAY:
		retval = "Bad gateway"

	case SERVICE_UNAVAILABLE:
		retval = "Service unavailable"

	case SERVER_TIMEOUT:
		retval = "Gateway timeout"

	case VERSION_NOT_SUPPORTED:
		retval = "SIP version not supported"

	case MESSAGE_TOO_LARGE:
		retval = "Message Too Large"

	case BUSY_EVERYWHERE:
		retval = "Busy everywhere"

	case DECLINE:
		retval = "Decline"

	case DOES_NOT_EXIST_ANYWHERE:
		retval = "Does not exist anywhere"

	case SESSION_NOT_ACCEPTABLE:
		retval = "Session Not acceptable"

	default:
		retval = ""

	}
	return retval

}

//    /** Set the status code.
//     *@param statusCode is the status code to Set.
//     *@throws IlegalArgumentException if invalid status code.
//     */
func (this *SIPResponse) SetStatusCode(statusCode int) { //throws ParseException {
	// if (statusCode < 100 || statusCode > 800)
	//     throw new ParseException("bad status code",0);
	if this.statusLine == nil {
		this.statusLine = header.NewStatusLine()
	}
	this.statusLine.SetStatusCode(statusCode)
}
Exemple #2
0
/** Constructor.
 */
func NewSIPResponse() *SIPResponse {
	this := &SIPResponse{}
	this.SIPMessage.super()
	return this
}

func (this *SIPResponse) GetReasonPhraseFromInt(rc int) string {
	var retval string
	switch rc {
	case TRYING:
		retval = "Trying"

	case RINGING:
		retval = "Ringing"

	case CALL_IS_BEING_FORWARDED:
		retval = "Call is being forwarded"

	case QUEUED:
		retval = "Queued"

	case SESSION_PROGRESS:
		retval = "Session progress"

	case OK:
		retval = "OK"

	case ACCEPTED:
		retval = "Accepted"

	case MULTIPLE_CHOICES:
		retval = "Multiple choices"

	case MOVED_PERMANENTLY:
		retval = "Moved permanently"

	case MOVED_TEMPORARILY:
		retval = "Moved Temporarily"

	case USE_PROXY:
		retval = "Use proxy"

	case ALTERNATIVE_SERVICE:
		retval = "Alternative service"

	case BAD_REQUEST:
		retval = "Bad request"

	case UNAUTHORIZED:
		retval = "Unauthorized"

	case PAYMENT_REQUIRED:
		retval = "Payment required"

	case FORBIDDEN:
		retval = "Forbidden"

	case NOT_FOUND:
		retval = "Not found"

	case METHOD_NOT_ALLOWED:
		retval = "Method not allowed"

	case NOT_ACCEPTABLE:
		retval = "Not acceptable"

	case PROXY_AUTHENTICATION_REQUIRED:
		retval = "Proxy Authentication required"

	case REQUEST_TIMEOUT:
		retval = "Request timeout"

	case GONE:
		retval = "Gone"

	case TEMPORARILY_UNAVAILABLE:
		retval = "Temporarily Unavailable"

	case REQUEST_ENTITY_TOO_LARGE:
		retval = "Request entity too large"

	case REQUEST_URI_TOO_LONG:
		retval = "Request-URI too large"

	case UNSUPPORTED_MEDIA_TYPE:
		retval = "Unsupported media type"

	case UNSUPPORTED_URI_SCHEME:
		retval = "Unsupported URI Scheme"

	case BAD_EXTENSION:
		retval = "Bad extension"

	case EXTENSION_REQUIRED:
		retval = "Etension Required"

	case INTERVAL_TOO_BRIEF:
		retval = "Interval too brief"

	case CALL_OR_TRANSACTION_DOES_NOT_EXIST:
		retval = "Call leg/Transaction does not exist"

	case LOOP_DETECTED:
		retval = "Loop detected"

	case TOO_MANY_HOPS:
		retval = "Too many hops"

	case ADDRESS_INCOMPLETE:
		retval = "Address incomplete"

	case AMBIGUOUS:
		retval = "Ambiguous"

	case BUSY_HERE:
		retval = "Busy here"

	case REQUEST_TERMINATED:
		retval = "Request Terminated"

	case NOT_ACCEPTABLE_HERE:
		retval = "Not Accpetable here"

	case BAD_EVENT:
		retval = "Bad Event"

	case REQUEST_PENDING:
		retval = "Request Pending"

	case SERVER_INTERNAL_ERROR:
		retval = "Server Internal Error"

	case UNDECIPHERABLE:
		retval = "Undecipherable"

	case NOT_IMPLEMENTED:
		retval = "Not implemented"

	case BAD_GATEWAY:
		retval = "Bad gateway"

	case SERVICE_UNAVAILABLE:
		retval = "Service unavailable"

	case SERVER_TIMEOUT:
		retval = "Gateway timeout"

	case VERSION_NOT_SUPPORTED:
		retval = "SIP version not supported"

	case MESSAGE_TOO_LARGE:
		retval = "Message Too Large"

	case BUSY_EVERYWHERE:
		retval = "Busy everywhere"

	case DECLINE:
		retval = "Decline"

	case DOES_NOT_EXIST_ANYWHERE:
		retval = "Does not exist anywhere"

	case SESSION_NOT_ACCEPTABLE:
		retval = "Session Not acceptable"

	default:
		retval = ""

	}
	return retval

}

//    /** Set the status code.
//     *@param statusCode is the status code to Set.
//     *@throws IlegalArgumentException if invalid status code.
//     */
func (this *SIPResponse) SetStatusCode(statusCode int) { //throws ParseException {
	// if (statusCode < 100 || statusCode > 800)
	//     throw new ParseException("bad status code",0);
	if this.statusLine == nil {
		this.statusLine = header.NewStatusLine()
	}
	this.statusLine.SetStatusCode(statusCode)
}

//    /**
//     * Get the status line of the response.
//     *@return StatusLine
//     */
func (this *SIPResponse) GetStatusLine() *header.StatusLine {
	return this.statusLine
}

//    /** Get the staus code (conveniance function).
//     *@return the status code of the status line.
//     */
func (this *SIPResponse) GetStatusCode() int {
	return this.statusLine.GetStatusCode()
}

//    /** Set the reason phrase.
//     *@param reasonPhrase the reason phrase.
//     *@throws IllegalArgumentException if nil string
//     */
func (this *SIPResponse) SetReasonPhrase(reasonPhrase string) {
	//if this.reasonPhrase == nil)
	//    throw new IllegalArgumentException("Bad reason phrase");
	if this.statusLine == nil {
		this.statusLine = header.NewStatusLine()
	}
	this.statusLine.SetReasonPhrase(reasonPhrase)
}
Exemple #3
0
func (this *StatusLineParser) Parse() (sl *header.StatusLine, ParseException error) {
	retval := header.NewStatusLine()
	lexer := this.GetLexer()

	var version string
	if version, ParseException = this.SipVersion(); ParseException != nil {
		return nil, ParseException
	}
	retval.SetSipVersion(version)
	lexer.SPorHT()

	var scode int
	if scode, ParseException = this.StatusCode(); ParseException != nil {
		return nil, ParseException
	}
	retval.SetStatusCode(scode)
	lexer.SPorHT()
	rp := this.ReasonPhrase()
	retval.SetReasonPhrase(rp)
	lexer.SPorHT()
	return retval, nil
}