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

C# WebSocketMessageType类代码示例

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

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



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

示例1: WebSocketMessageWriteRfc6455Stream

 public WebSocketMessageWriteRfc6455Stream(WebSocketRfc6455 client, WebSocketMessageType messageType, WebSocketExtensionFlags extensionFlags)
     : this(client, messageType)
 {
     ExtensionFlags.Rsv1 = extensionFlags.Rsv1;
     ExtensionFlags.Rsv2 = extensionFlags.Rsv2;
     ExtensionFlags.Rsv3 = extensionFlags.Rsv3;
 }
开发者ID:papci,项目名称:WebSocketListener,代码行数:7,代码来源:WebSocketMessageWriteRfc6455Stream.cs


示例2: SendAsync

        public virtual Task SendAsync(ArraySegment<byte> message, WebSocketMessageType messageType, bool endOfMessage = true)
        {
            if (WebSocket.State != WebSocketState.Open)
            {
                return TaskAsyncHelper.Empty;
            }

            var sendContext = new SendContext(this, message, messageType, endOfMessage);

            return _sendQueue.Enqueue(async state =>
            {
                var context = (SendContext)state;

                if (context.Handler.WebSocket.State != WebSocketState.Open)
                {
                    return;
                }

                try
                {
                    await context.Handler.WebSocket.SendAsync(context.Message, context.MessageType, context.EndOfMessage, CancellationToken.None);
                }
                catch (Exception ex)
                {
                    // Swallow exceptions on send
                    Trace.TraceError("Error while sending: " + ex);
                }
            },
            sendContext);
        }
开发者ID:GaneshBachhao,项目名称:SignalR,代码行数:30,代码来源:WebSocketHandler.cs


示例3: OnMessageReceived

        public override Task OnMessageReceived(ArraySegment<byte> message, WebSocketMessageType type)
        {
            if (this.MessageReceived != null)
                this.MessageReceived(this, new SocketMessage(this.Id, new UTF8Encoding().GetString(message.Array)));

            return base.OnMessageReceived(message, type);
        }
开发者ID:meungblut,项目名称:Websockets,代码行数:7,代码来源:OwinWebSocketConnection.cs


示例4: TestChatHanlder_OnReceive

 private void TestChatHanlder_OnReceive(WebSocket Socket, WebSocketMessageType Type, byte[] ReceiveMessage)
 {
     //並行廣播給所有使用者,也可以轉發給指定使用者
     Parallel.ForEach(WebSocketList, async socket => {
         await socket.SendAsync(new ArraySegment<byte>(ReceiveMessage), Type, true, CancellationToken.None);
     });
 }
开发者ID:XuPeiYao,项目名称:AspNetCoreTemplate,代码行数:7,代码来源:TestChatHanlder.cs


示例5: WebSocketMessageProperty

 internal WebSocketMessageProperty(WebSocketContext context, string subProtocol, WebSocketMessageType incomingMessageType, ReadOnlyDictionary<string, object> properties)
 {
     this.context = context;
     this.subProtocol = subProtocol;
     this.messageType = incomingMessageType;
     this.properties = properties;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:WebSocketMessageProperty.cs


示例6: GetWinHttpMessageType

        internal static Interop.WinHttp.WINHTTP_WEB_SOCKET_BUFFER_TYPE GetWinHttpMessageType(WebSocketMessageType messageType, bool endOfMessage)
        {
            switch (messageType)
            {
                case WebSocketMessageType.Binary:
                    if (endOfMessage)
                    {
                        return Interop.WinHttp.WINHTTP_WEB_SOCKET_BUFFER_TYPE.WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE;
                    }
                    else
                    {
                        return Interop.WinHttp.WINHTTP_WEB_SOCKET_BUFFER_TYPE.WINHTTP_WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE;
                    }

                case WebSocketMessageType.Text:
                    if (endOfMessage)
                    {
                        return Interop.WinHttp.WINHTTP_WEB_SOCKET_BUFFER_TYPE.WINHTTP_WEB_SOCKET_UTF8_MESSAGE_BUFFER_TYPE;
                    }
                    else
                    {
                        return Interop.WinHttp.WINHTTP_WEB_SOCKET_BUFFER_TYPE.WINHTTP_WEB_SOCKET_UTF8_FRAGMENT_BUFFER_TYPE;
                    }

                case WebSocketMessageType.Close:
                    return Interop.WinHttp.WINHTTP_WEB_SOCKET_BUFFER_TYPE.WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE;

                default:
                    Debug.Fail("Unknown WebSocketMessageType.");
                    return Interop.WinHttp.WINHTTP_WEB_SOCKET_BUFFER_TYPE.WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE;
            }
        }
开发者ID:er0dr1guez,项目名称:corefx,代码行数:32,代码来源:WebSocketMessageTypeAdapter.cs


示例7: SendContext

 public SendContext(ArraySegment<byte> buffer, bool endOfMessage, WebSocketMessageType type, CancellationToken cancelToken)
 {
     this.Buffer = buffer;
     this.EndOfMessage = endOfMessage;
     this.Type = type;
     this.CancelToken = cancelToken;
 }
开发者ID:meungblut,项目名称:Websockets,代码行数:7,代码来源:SendContext.cs


示例8: PendingSend

 public PendingSend(TaskCompletionSource<bool> tcs, WebSocketMessageType type, ArraySegment<byte> buffer, CancellationToken cancellationToken)
 {
     Type = type;
     _tcs = tcs;
     Buffer = buffer;
     CancellationToken = cancellationToken;
 }
开发者ID:tmds,项目名称:Tmds.SockJS,代码行数:7,代码来源:PendingSend.cs


示例9: SendAsync

 public Task SendAsync(
     ArraySegment<byte> bytes,
     WebSocketMessageType webSocketMessageType,
     bool endOfMessage,
     CancellationToken cancellationToken)
 {
     return this.socket.SendAsync(bytes, webSocketMessageType, endOfMessage, cancellationToken);
 }
开发者ID:meungblut,项目名称:Websockets,代码行数:8,代码来源:DotNetWebSocketClient.cs


示例10: SendAsync

 public Task SendAsync(
     ArraySegment<byte> buffer,
     WebSocketMessageType messageType,
     bool endOfMessage,
     CancellationToken cancellationToken)
 {
     throw new PlatformNotSupportedException(SR.net_WebSockets_UnsupportedPlatform);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:WebSocketHandle.Unix.cs


示例11: SendAsync

 public Task SendAsync(
     ArraySegment<byte> buffer,
     WebSocketMessageType messageType,
     bool endOfMessage,
     CancellationToken cancellationToken)
 {
     return _webSocket.SendAsync(buffer, messageType, endOfMessage, cancellationToken);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:WebSocketHandle.Windows.cs


示例12: SendAsync

 public Task SendAsync(
     ArraySegment<byte> bytes,
     WebSocketMessageType webSocketMessageType,
     bool endOfMessage,
     CancellationToken cancellationToken)
 {
     return Task.Run(() => this.socket.Send(new[] { bytes }), cancellationToken);
 }
开发者ID:meungblut,项目名称:Websockets,代码行数:8,代码来源:WebSocket4NetSocketClient.cs


示例13: WebSocketReceiveResult

		public WebSocketReceiveResult (int count,
		                               WebSocketMessageType messageType,
		                               bool endOfMessage,
		                               WebSocketCloseStatus? closeStatus,
		                               string closeStatusDescription)
		{
			throw new NotImplementedException ();
		}
开发者ID:symform,项目名称:mono,代码行数:8,代码来源:WebSocketReceiveResult.cs


示例14: ConstructorTest_Success

 public void ConstructorTest_Success(int count, WebSocketMessageType messageType, bool endOfMessage, WebSocketCloseStatus? closeStatus, string closeStatusDescription)
 {
     var wsrr = new WebSocketReceiveResult(count, messageType, endOfMessage, closeStatus, closeStatusDescription);
     Assert.Equal(wsrr.Count, count);
     Assert.Equal(wsrr.MessageType, messageType);
     Assert.Equal(wsrr.EndOfMessage, endOfMessage);
     Assert.Equal(wsrr.CloseStatus, closeStatus);
     Assert.Equal(wsrr.CloseStatusDescription, closeStatusDescription);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:9,代码来源:WebSocketReceiveResultTests.cs


示例15: WebSocketMessageWriteRfc6455Stream

        public WebSocketMessageWriteRfc6455Stream(WebSocketRfc6455 webSocket, WebSocketMessageType messageType)
        {
            if (webSocket == null)
                throw new ArgumentNullException("webSocket");

            _internalUsedBufferLength = 0;
            _messageType = messageType;
            _webSocket = webSocket;
        }
开发者ID:Nepomuceno,项目名称:WebSocketListener,代码行数:9,代码来源:WebSocketMessageWriteRfc6455Stream.cs


示例16: CreateMessageWriter

        public override WebSocketMessageWriteStream CreateMessageWriter(WebSocketMessageType messageType)
        {
            Connection.BeginWritting();
            WebSocketMessageWriteStream writer = new WebSocketMessageWriteRfc6455Stream(this, messageType);

            foreach (var extension in _extensions)
                writer = extension.ExtendWriter(writer);

            return writer;
        }
开发者ID:Nepomuceno,项目名称:WebSocketListener,代码行数:10,代码来源:WebSocketRfc6455.cs


示例17: CreateMessage

        private Message CreateMessage(byte[] message,
            WebSocketMessageType type = WebSocketMessageType.Binary)
        {
            Message channelMessage = ByteStreamMessage.CreateMessage(new ArraySegment<byte>(message));

            channelMessage.Properties[webSocketMessageProperty] =
                new WebSocketMessageProperty { MessageType = type };

            return channelMessage;
        }
开发者ID:tewarid,项目名称:NetTools,代码行数:10,代码来源:Service.cs


示例18: GetOpCode

 public static int GetOpCode(WebSocketMessageType messageType)
 {
     switch (messageType)
     {
         case WebSocketMessageType.Text: return Constants.OpCodes.TextFrame;
         case WebSocketMessageType.Binary: return Constants.OpCodes.BinaryFrame;
         case WebSocketMessageType.Close: return Constants.OpCodes.CloseFrame;
         default: throw new NotImplementedException(messageType.ToString());
     }
 }
开发者ID:nimishbhonsale,项目名称:WebSockets,代码行数:10,代码来源:Utilities.cs


示例19: Send

        public Task Send(ArraySegment<byte> data, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancelToken)
        {
            var sendContext = new SendContext(data, endOfMessage, messageType, cancelToken);

            return this.mSendQueue.Enqueue(
                async s =>
                {
                    await this.mSendAsync(s.Buffer, MessageTypeEnumToOpCode(s.Type), s.EndOfMessage, s.CancelToken);
                },
                sendContext);
        }
开发者ID:meungblut,项目名称:Websockets,代码行数:11,代码来源:OwinWebSocket.cs


示例20: SendAsync

        /// <summary>
        /// Sends data to the client
        /// </summary>
        /// <param name="buffer">Data to send</param>
        /// <param name="endOfMessage">End of the message?</param>
        /// <param name="type">Message type of the data</param>
        /// <returns>Task to send the data</returns>
        public Task SendAsync(ArraySegment<byte> buffer, bool endOfMessage, WebSocketMessageType type)
        {
            var sendContext = new SendContext { Buffer = buffer, EndOfMessage = endOfMessage, Type = type };

            return mSendQueue.Enqueue(
                async s =>
                    {
                        await mWebSocket.SendAsync(s.Buffer, s.Type, s.EndOfMessage, CancellationToken.None);
                    },
                sendContext);
        }
开发者ID:kbekkenutte,项目名称:Owin.WebSocket,代码行数:18,代码来源:WebSocketConnection.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# WebSocketServer类代码示例发布时间:2022-05-24
下一篇:
C# WebSocketFrame类代码示例发布时间: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