• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WebSocketError类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WebSocketError的典型用法代码示例。如果您正苦于以下问题:C# WebSocketError类的具体用法?C# WebSocketError怎么用?C# WebSocketError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WebSocketError类属于命名空间,在下文中一共展示了WebSocketError类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ConstructorTests_WebSocketError_Success

 public void ConstructorTests_WebSocketError_Success(WebSocketError error)
 {
     var wse = new WebSocketException(error);
     Assert.Equal(error, wse.WebSocketErrorCode);
     Assert.NotEqual("", wse.Message);
     Assert.Null(wse.InnerException);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:WebSocketExceptionTests.cs


示例2: ConstructorTests_NativeError_Success

 public void ConstructorTests_NativeError_Success(int nativeError, WebSocketError webSocketError)
 {
     var wse = new WebSocketException(nativeError);
     Assert.Equal(wse.HResult, nativeError);
     Assert.Equal(wse.WebSocketErrorCode, webSocketError);
     Assert.NotEqual(wse.Message, "");
     Assert.Null(wse.InnerException);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:8,代码来源:WebSocketExceptionTests.cs


示例3: ConstructorTests_WebSocketError_Exception_Success

 public void ConstructorTests_WebSocketError_Exception_Success(WebSocketError error)
 {
     var inner = new Exception();
     var wse = new WebSocketException(error, inner);
     Assert.Equal(error, wse.WebSocketErrorCode);
     Assert.NotEqual("", wse.Message);
     Assert.Same(inner, wse.InnerException);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:WebSocketExceptionTests.cs


示例4: ConstructorTests_NativeError_Success

 public void ConstructorTests_NativeError_Success(int nativeError, WebSocketError webSocketError, int expectedHResult)
 {
     var wse = new WebSocketException(nativeError);
     Assert.Equal(expectedHResult, wse.HResult);
     Assert.Equal(webSocketError, wse.WebSocketErrorCode);
     Assert.NotEqual("", wse.Message);
     Assert.Null(wse.InnerException);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:WebSocketExceptionTests.cs


示例5: ConstructorTests_WebSocketError_Message_Success

 public void ConstructorTests_WebSocketError_Message_Success(WebSocketError error)
 {
     const string Message = "Message";
     var wse = new WebSocketException(error, Message);
     Assert.Equal(error, wse.WebSocketErrorCode);
     Assert.Equal(Message, wse.Message);
     Assert.Null(wse.InnerException);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:8,代码来源:WebSocketExceptionTests.cs


示例6: ConstructorTests_WebSocketError_Message_Exception_Success

 public void ConstructorTests_WebSocketError_Message_Exception_Success(WebSocketError error)
 {
     const string Message = "Message";
     var inner = new Exception();
     var wse = new WebSocketException(error, Message, inner);
     Assert.Equal(wse.WebSocketErrorCode, error);
     Assert.Equal(wse.Message, Message);
     Assert.Equal(wse.InnerException, inner);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:WebSocketExceptionTests.cs


示例7: ConstructorTests_NativeError_Message_Success

 public void ConstructorTests_NativeError_Message_Success(int nativeError, WebSocketError webSocketError)
 {
     const string Message = "Message";
     var wse = new WebSocketException(nativeError, Message);
     Assert.Equal(wse.HResult, nativeError);
     Assert.Equal(wse.WebSocketErrorCode, webSocketError);
     Assert.Equal(wse.Message, Message);
     Assert.Null(wse.InnerException);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:WebSocketExceptionTests.cs


示例8: WebSocketException

		public WebSocketException (WebSocketError error, int nativeError) : this (error, nativeError, DefaultMessage, null)
		{
		}
开发者ID:Profit0004,项目名称:mono,代码行数:3,代码来源:WebSocketException.cs


示例9: ConstructorTests_WebSocketError_NativeError_Exception_Success

 public void ConstructorTests_WebSocketError_NativeError_Exception_Success(int nativeError, WebSocketError error)
 {
     var inner = new Exception();
     var wse = new WebSocketException(error, nativeError, inner);
     Assert.Equal(wse.HResult, nativeError);
     Assert.Equal(wse.WebSocketErrorCode, error);
     Assert.NotEqual(wse.Message, "");
     Assert.Equal(wse.InnerException, inner);
 }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:9,代码来源:WebSocketExceptionTests.cs


示例10: WebSocketException

 public WebSocketException(WebSocketError error, int nativeError)
     : this(error, nativeError, GetErrorMessage(error))
 {
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:4,代码来源:WebSocketException.cs


示例11: GetErrorMessage

 private static string GetErrorMessage(WebSocketError error)
 {
     // provide a canned message for the error type
     switch (error)
     {
         case WebSocketError.InvalidMessageType:
             return SR.GetString(SR.net_WebSockets_InvalidMessageType_Generic,
                 typeof(WebSocket).Name + WebSocketBase.Methods.CloseAsync,
                 typeof(WebSocket).Name + WebSocketBase.Methods.CloseOutputAsync);
         case WebSocketError.Faulted:
             return SR.GetString(SR.net_Websockets_WebSocketBaseFaulted);
         case WebSocketError.NotAWebSocket:
             return SR.GetString(SR.net_WebSockets_NotAWebSocket_Generic);
         case WebSocketError.UnsupportedVersion:
             return SR.GetString(SR.net_WebSockets_UnsupportedWebSocketVersion_Generic);
         case WebSocketError.UnsupportedProtocol:
             return SR.GetString(SR.net_WebSockets_UnsupportedProtocol_Generic);
         case WebSocketError.HeaderError:
             return SR.GetString(SR.net_WebSockets_HeaderError_Generic);
         case WebSocketError.ConnectionClosedPrematurely:
             return SR.GetString(SR.net_WebSockets_ConnectionClosedPrematurely_Generic);
         case WebSocketError.InvalidState:
             return SR.GetString(SR.net_WebSockets_InvalidState_Generic);
         default:
             return SR.GetString(SR.net_WebSockets_Generic);
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:27,代码来源:WebSocketException.cs


示例12: ConstructorTests_WebSocketError_NativeError_Message_Exception_Success

 public void ConstructorTests_WebSocketError_NativeError_Message_Exception_Success(int nativeError, WebSocketError error, int expectedHResult)
 {
     const string Message = "Message";
     var inner = new Exception();
     var wse = new WebSocketException(error, nativeError, Message, inner);
     Assert.Equal(expectedHResult, wse.HResult);
     Assert.Equal(error, wse.WebSocketErrorCode);
     Assert.Equal(Message, wse.Message);
     Assert.Same(inner, wse.InnerException);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:10,代码来源:WebSocketExceptionTests.cs


示例13: GetErrorMessage

 private static string GetErrorMessage(WebSocketError error)
 {
     // Provide a canned message for the error type.
     switch (error)
     {
         case WebSocketError.InvalidMessageType:
             return SR.Format(SR.net_WebSockets_InvalidMessageType_Generic,
                 $"{nameof(WebSocket)}.{nameof(WebSocket.CloseAsync)}",
                 $"{nameof(WebSocket)}.{nameof(WebSocket.CloseOutputAsync)}");
         case WebSocketError.Faulted:
             return SR.net_Websockets_WebSocketBaseFaulted;
         case WebSocketError.NotAWebSocket:
             return SR.net_WebSockets_NotAWebSocket_Generic;
         case WebSocketError.UnsupportedVersion:
             return SR.net_WebSockets_UnsupportedWebSocketVersion_Generic;
         case WebSocketError.UnsupportedProtocol:
             return SR.net_WebSockets_UnsupportedProtocol_Generic;
         case WebSocketError.HeaderError:
             return SR.net_WebSockets_HeaderError_Generic;
         case WebSocketError.ConnectionClosedPrematurely:
             return SR.net_WebSockets_ConnectionClosedPrematurely_Generic;
         case WebSocketError.InvalidState:
             return SR.net_WebSockets_InvalidState_Generic;
         default:
             return SR.net_WebSockets_Generic;
     }
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:27,代码来源:WebSocketException.cs


示例14: AssertWebSocketException

		void AssertWebSocketException (AggregateException e, WebSocketError error, Type inner = null)
		{
			var wsEx = e.InnerException as WebSocketException;
			Console.WriteLine (e.InnerException.ToString ());
			Assert.IsNotNull (wsEx, "Not a websocketexception");
			Assert.AreEqual (error, wsEx.WebSocketErrorCode);
			if (inner != null) {
				Assert.IsNotNull (wsEx.InnerException);
				Assert.IsTrue (inner.IsInstanceOfType (wsEx.InnerException));
			}
		}
开发者ID:nslAnil,项目名称:mono,代码行数:11,代码来源:ClientWebSocketTest.cs


示例15: CloseWithReceiveErrorAndThrowAsync

        /// <summary>Send a close message to the server and throw an exception, in response to getting bad data from the server.</summary>
        /// <param name="closeStatus">The close status code to use.</param>
        /// <param name="error">The error reason.</param>
        /// <param name="cancellationToken">The CancellationToken used to cancel the websocket.</param>
        /// <param name="innerException">An optional inner exception to include in the thrown exception.</param>
        private async Task CloseWithReceiveErrorAndThrowAsync(
            WebSocketCloseStatus closeStatus, WebSocketError error, CancellationToken cancellationToken, Exception innerException = null)
        {
            // Close the connection if it hasn't already been closed
            if (!_sentCloseFrame)
            {
                await CloseOutputAsync(closeStatus, string.Empty, cancellationToken).ConfigureAwait(false);
            }

            // Dump our receive buffer; we're in a bad state to do any further processing
            _receiveBufferCount = 0;

            // Let the caller know we've failed
            throw new WebSocketException(error, innerException);
        }
开发者ID:swaroop-sridhar,项目名称:corefx,代码行数:20,代码来源:ManagedWebSocket.cs


示例16: WebSocketException

 public WebSocketException(int nativeError, string message)
     : base(nativeError, message)
 {
     _webSocketErrorCode = !Succeeded(nativeError) ? WebSocketError.NativeError : WebSocketError.Success;
     SetErrorCodeOnError(nativeError);
 }
开发者ID:rparsi,项目名称:corefx,代码行数:6,代码来源:WebSocketException.cs


示例17: WebSocketException

		public WebSocketException (WebSocketError error, int nativeError, string message) : base (nativeError, message)
		{
			WebSocketErrorCode = error;
		}
开发者ID:symform,项目名称:mono,代码行数:4,代码来源:WebSocketException.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WebSocketFrame类代码示例发布时间:2022-05-24
下一篇:
C# WebSocketContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap