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

C# WebSocketFrame类代码示例

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

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



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

示例1: WebSocketFrameParseResult

        public WebSocketFrameParseResult(WebSocketFrame webSocketFrame, byte[] overhead)
        {
            if (webSocketFrame == null) throw new ArgumentNullException(nameof(webSocketFrame));
            if (overhead == null) throw new ArgumentNullException(nameof(overhead));

            WebSocketFrame = webSocketFrame;
            Overhead = overhead;
        }
开发者ID:chkr1011,项目名称:CK.HomeAutomation,代码行数:8,代码来源:WebSocketFrameParseResult.cs


示例2: MessageEventArgs

 internal MessageEventArgs(WebSocketFrame frame)
 {
     _opcode = frame.Opcode;
       _rawData = frame.PayloadData.ApplicationData;
       _data = convertToString (_opcode, _rawData);
 }
开发者ID:pedro-ramirez-suarez,项目名称:DiPS,代码行数:6,代码来源:MessageEventArgs.cs


示例3: checkIfValidReceivedFrame

 private string checkIfValidReceivedFrame (WebSocketFrame frame)
 {
   var masked = frame.IsMasked;
   return _client && masked
          ? "A frame from the server is masked."
          : !_client && !masked
            ? "A frame from a client isn't masked."
            : _inContinuation && frame.IsData
              ? "A data frame has been received while receiving the fragmented data."
              : frame.IsCompressed && _compression == CompressionMethod.None
                ? "A compressed frame is without an available decompression method."
                : null;
 }
开发者ID:greeduomacro,项目名称:uomap-client,代码行数:13,代码来源:WebSocket.cs


示例4: processUnsupportedFrame

    private bool processUnsupportedFrame (WebSocketFrame frame, CloseStatusCode code, string reason)
    {
      _logger.Debug ("An unsupported frame:" + frame.PrintToString (false));
      processException (new WebSocketException (code, reason), null);

      return false;
    }
开发者ID:greeduomacro,项目名称:uomap-client,代码行数:7,代码来源:WebSocket.cs


示例5: processPongFrame

    private bool processPongFrame (WebSocketFrame frame)
    {
      _receivePong.Set ();
      _logger.Trace ("Received a Pong.");

      return true;
    }
开发者ID:greeduomacro,项目名称:uomap-client,代码行数:7,代码来源:WebSocket.cs


示例6: processFragmentedFrame

    private bool processFragmentedFrame (WebSocketFrame frame)
    {
      if (!_inContinuation) {
        // Must process first fragment.
        if (frame.IsContinuation)
          return true;

        _fopcode = frame.Opcode;
        _fragmentsBuffer = new MemoryStream ();
        _inContinuation = true;
      }

      _fragmentsBuffer.WriteBytes (frame.PayloadData.ApplicationData);
      if (frame.IsFinal) {
        using (_fragmentsBuffer) {
          var data = _compression != CompressionMethod.None
                     ? _fragmentsBuffer.DecompressToArray (_compression)
                     : _fragmentsBuffer.ToArray ();

          enqueueToMessageEventQueue (new MessageEventArgs (_fopcode, data));
        }

        _fragmentsBuffer = null;
        _inContinuation = false;
      }

      return true;
    }
开发者ID:greeduomacro,项目名称:uomap-client,代码行数:28,代码来源:WebSocket.cs


示例7: checkReceivedFrame

    private bool checkReceivedFrame (WebSocketFrame frame, out string message)
    {
      message = null;

      var masked = frame.IsMasked;
      if (_client && masked) {
        message = "A frame from the server is masked.";
        return false;
      }

      if (!_client && !masked) {
        message = "A frame from a client isn't masked.";
        return false;
      }

      if (_inContinuation && frame.IsData) {
        message = "A data frame has been received while receiving continuation frames.";
        return false;
      }

      if (frame.IsCompressed && _compression == CompressionMethod.None) {
        message = "A compressed frame has been received without any agreement for it.";
        return false;
      }

      if (frame.Rsv2 == Rsv.On) {
        message = "The RSV2 of a frame is non-zero without any negotiation for it.";
        return false;
      }

      if (frame.Rsv3 == Rsv.On) {
        message = "The RSV3 of a frame is non-zero without any negotiation for it.";
        return false;
      }

      return true;
    }
开发者ID:rejemy,项目名称:serverville-client-unity,代码行数:37,代码来源:WebSocket.cs


示例8: processFragmentedFrame

 private bool processFragmentedFrame(WebSocketFrame frame)
 {
     return frame.IsContinuation // Not first fragment
            ? true
            : processFragments(frame);
 }
开发者ID:WJ-GitHub,项目名称:SocketHttpListener,代码行数:6,代码来源:WebSocket.cs


示例9: processPingFrame

        private bool processPingFrame(WebSocketFrame frame)
        {
            var mask = Mask.Unmask;

            return true;
        }
开发者ID:WJ-GitHub,项目名称:SocketHttpListener,代码行数:6,代码来源:WebSocket.cs


示例10: send

        private bool send(WebSocketFrame frame)
        {
            lock (_forConn) {
            if (_readyState != WebSocketState.Open) {
              _logger.Warn ("Sending has been interrupted.");
              return false;
            }

            return _stream.Write (frame.ToByteArray ());
              }
        }
开发者ID:MylesBell,项目名称:Unity,代码行数:11,代码来源:WebSocket.cs


示例11: processCloseFrame

        private bool processCloseFrame(WebSocketFrame frame)
        {
            var payload = frame.PayloadData;
            close(payload, !payload.ContainsReservedCloseStatusCode, false);

            return false;
        }
开发者ID:WJ-GitHub,项目名称:SocketHttpListener,代码行数:7,代码来源:WebSocket.cs


示例12: acceptPingFrame

        private bool acceptPingFrame(WebSocketFrame frame)
        {
            var mask = _client ? Mask.Mask : Mask.Unmask;
              if (send (WebSocketFrame.CreatePongFrame (mask, frame.PayloadData)))
            _logger.Trace ("Returned a Pong.");

              return true;
        }
开发者ID:MylesBell,项目名称:Unity,代码行数:8,代码来源:WebSocket.cs


示例13: OpCodeText

 public void OpCodeText(object sender, FrameEventArgs e)
 {
     WebSocketFrame frame = new WebSocketFrame(ASCIIEncoding.UTF8.GetBytes("Echo: " + e.frame.PayloadAsUTF8()));
     e.clientConnection.Send(frame.AsBytes());
 }
开发者ID:Technicalfool,项目名称:Telemachus,代码行数:5,代码来源:MinimalWebSocketServerTest.cs


示例14: processCloseFrame

        private bool processCloseFrame(WebSocketFrame frame)
        {
            enqueueToMessageEventQueue(new MessageEventArgs(frame));

              return false;
        }
开发者ID:cswiedler,项目名称:websocket-sharp,代码行数:6,代码来源:WebSocket.cs


示例15: processReceivedFrame

    private bool processReceivedFrame (WebSocketFrame frame)
    {
      string msg;
      if (!checkReceivedFrame (frame, out msg))
        throw new WebSocketException (CloseStatusCode.ProtocolError, msg);

      frame.Unmask ();
      return frame.IsFragment
             ? processFragmentFrame (frame)
             : frame.IsData
               ? processDataFrame (frame)
               : frame.IsPing
                 ? processPingFrame (frame)
                 : frame.IsPong
                   ? processPongFrame (frame)
                   : frame.IsClose
                     ? processCloseFrame (frame)
                     : processUnsupportedFrame (frame);
    }
开发者ID:rejemy,项目名称:serverville-client-unity,代码行数:19,代码来源:WebSocket.cs


示例16: processPongFrame

        private bool processPongFrame(WebSocketFrame frame)
        {
            _receivePong.Set();

            return true;
        }
开发者ID:WJ-GitHub,项目名称:SocketHttpListener,代码行数:6,代码来源:WebSocket.cs


示例17: processUnsupportedFrame

    private bool processUnsupportedFrame (WebSocketFrame frame)
    {
      _logger.Fatal ("An unsupported frame:" + frame.PrintToString (false));
      fatal ("There is no way to handle it.", CloseStatusCode.PolicyViolation);

      return false;
    }
开发者ID:rejemy,项目名称:serverville-client-unity,代码行数:7,代码来源:WebSocket.cs


示例18: processUnsupportedFrame

        private bool processUnsupportedFrame(WebSocketFrame frame, CloseStatusCode code, string reason)
        {
            processException(new WebSocketException(code, reason), null);

            return false;
        }
开发者ID:WJ-GitHub,项目名称:SocketHttpListener,代码行数:6,代码来源:WebSocket.cs


示例19: MessageEventArgs

 internal MessageEventArgs(WebSocketFrame frame)
 {
     _opcode = frame.Opcode;
     _rawData = frame.PayloadData.ApplicationData;
 }
开发者ID:cliftonm,项目名称:clifton,代码行数:5,代码来源:MessageEventArgs.cs


示例20: processWebSocketFrame

 private bool processWebSocketFrame(WebSocketFrame frame)
 {
     return frame.IsCompressed && _compression == CompressionMethod.None
            ? processUnsupportedFrame(
                frame,
                CloseStatusCode.IncorrectData,
                "A compressed data has been received without available decompression method.")
            : frame.IsFragmented
              ? processFragmentedFrame(frame)
              : frame.IsData
                ? processDataFrame(frame)
                : frame.IsPing
                  ? processPingFrame(frame)
                  : frame.IsPong
                    ? processPongFrame(frame)
                    : frame.IsClose
                      ? processCloseFrame(frame)
                      : processUnsupportedFrame(frame, CloseStatusCode.PolicyViolation, null);
 }
开发者ID:WJ-GitHub,项目名称:SocketHttpListener,代码行数:19,代码来源:WebSocket.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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