当前位置: 首页>>代码示例>>C#>>正文


C# Response.SetMessageType方法代码示例

本文整理汇总了C#中Response.SetMessageType方法的典型用法代码示例。如果您正苦于以下问题:C# Response.SetMessageType方法的具体用法?C# Response.SetMessageType怎么用?C# Response.SetMessageType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Response的用法示例。


在下文中一共展示了Response.SetMessageType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateBindingErrorResponse

        /**
         * Creates a binding error response according to the specified error code
         * and unknown attributes.
         *
         * @param errorCode the error code to encapsulate in this message
         * @param reasonPhrase a human readable description of the error
         * @param unknownAttributes a char[] array containing the ids of one or more
         * attributes that had not been recognized.
         * @throws StunException INVALID_ARGUMENTS if one or more of the given
         * parameters had an invalid value.
         *
         * @return a binding error response message containing an error code and a
         * UNKNOWN-ATTRIBUTES header
         */
        private static Response CreateBindingErrorResponse(int errorCode,
			String reasonPhrase,
			int[] unknownAttributes)
        {
            Response bindingErrorResponse = new Response();
            bindingErrorResponse.SetMessageType(Message.BINDING_ERROR_RESPONSE);

            //init attributes
            UnknownAttributesAttribute unknownAttributesAttribute = null;
            ErrorCodeAttribute errorCodeAttribute =
                AttributeFactory.CreateErrorCodeAttribute(errorCode,reasonPhrase);

            bindingErrorResponse.AddAttribute(errorCodeAttribute);

            if(unknownAttributes != null)
            {
                unknownAttributesAttribute = AttributeFactory.
                    CreateUnknownAttributesAttribute();
                for (int i = 0; i < unknownAttributes.Length; i++)
                {
                    unknownAttributesAttribute.AddAttributeID(unknownAttributes[i]);
                }
                bindingErrorResponse.AddAttribute(unknownAttributesAttribute);
            }

            return bindingErrorResponse;
        }
开发者ID:hughperkins,项目名称:osmp-cs,代码行数:41,代码来源:MessageFactory.cs

示例2: CreateBindingResponse

        /**
         * Creates a BindingResponse assigning the specified values to mandatory
         * headers.
         *
         * @param mappedAddress     the address to assign the mappedAddressAttribute
         * @param sourceAddress     the address to assign the sourceAddressAttribute
         * @param changedAddress    the address to assign the changedAddressAttribute
         * @return a BindingResponse assigning the specified values to mandatory
         *         headers.
         * @throws StunException ILLEGAL_ARGUMENT
         */
        public static Response CreateBindingResponse(StunAddress mappedAddress,
			StunAddress sourceAddress,
			StunAddress changedAddress)
        {
            Response bindingResponse = new Response();
            bindingResponse.SetMessageType(Message.BINDING_RESPONSE);

            //mapped address
            MappedAddressAttribute mappedAddressAttribute =
                AttributeFactory.CreateMappedAddressAttribute(mappedAddress);

            //source address
            SourceAddressAttribute sourceAddressAttribute =
                AttributeFactory.CreateSourceAddressAttribute(sourceAddress);

            //changed address
            ChangedAddressAttribute changedAddressAttribute =
                AttributeFactory.CreateChangedAddressAttribute(changedAddress);

            bindingResponse.AddAttribute(mappedAddressAttribute);
            bindingResponse.AddAttribute(sourceAddressAttribute);
            bindingResponse.AddAttribute(changedAddressAttribute);

            return bindingResponse;
        }
开发者ID:hughperkins,项目名称:osmp-cs,代码行数:36,代码来源:MessageFactory.cs


注:本文中的Response.SetMessageType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。