Example #1
0
        /**
         * Creates an ErrorCodeAttribute with the specified error code and reason
         * phrase.
         * @param errorCode a valid error code.
         * @param reasonPhrase a human readable reason phrase. A null reason phrase
         *                     would be replaced (if possible) by a default one
         *                     as defined byte the rfc3489.
         *
         * @return the newly created attribute.
         * @throws StunException if errorCode is not a valid error code as defined
         * by rfc3489
         */
        public static ErrorCodeAttribute CreateErrorCodeAttribute(
            int errorCode,
            String reasonPhrase)
        {
            ErrorCodeAttribute attribute = new ErrorCodeAttribute();

            attribute.SetErrorCode(errorCode);
            attribute.SetReasonPhrase(reasonPhrase == null?
                                      ErrorCodeAttribute.GetDefaultReasonPhrase(attribute.GetErrorCode())
                                :reasonPhrase);


            return(attribute);
        }