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

C# WebSocketContext类代码示例

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

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



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

示例1: Handle

 public override WebSocketPackageInfo Handle(IAppSession session, WebSocketContext context, IList<ArraySegment<byte>> data)
 {
     var total = data.Sum(d => d.Count);
     var payloadLength = context.PayloadLength;
     var text = Encoding.UTF8.GetString(data, total - payloadLength, payloadLength);
     return new WebSocketPackageInfo(text, ServiceProvider.StringParser);
 }
开发者ID:RocChing,项目名称:SuperSocket,代码行数:7,代码来源:TextHandler.cs


示例2: WebSocket

        // As server
        internal WebSocket(HttpListenerWebSocketContext context, string protocol)
        {
            _context = context;
            _protocol = protocol;

            _closeContext = context.Close;
            _secure = context.IsSecureConnection;
            _stream = context.Stream;

            init();
        }
开发者ID:WJ-GitHub,项目名称:SocketHttpListener,代码行数:12,代码来源:WebSocket.cs


示例3: WebSocket

 internal WebSocket(TcpListenerWebSocketContext context)
     : this()
 {
     _uri       = context.Path.ToUri();
       _context   = context;
       _tcpClient = context.Client;
       _wsStream  = context.Stream;
       _endPoint  = context.ServerEndPoint;
       _isClient  = false;
       _isSecure  = context.IsSecureConnection;
 }
开发者ID:pasanzaza,项目名称:Dragonbound,代码行数:11,代码来源:WebSocket.cs


示例4: customCheckHandshakeRequest

 // As server
 private bool customCheckHandshakeRequest (WebSocketContext context, out string message)
 {
   message = null;
   return _handshakeRequestChecker == null
          || (message = _handshakeRequestChecker (context)) == null;
 }
开发者ID:rejemy,项目名称:serverville-client-unity,代码行数:7,代码来源:WebSocket.cs


示例5: checkIfValidHandshakeRequest

 // As server
 private string checkIfValidHandshakeRequest (WebSocketContext context)
 {
   var headers = context.Headers;
   return context.RequestUri == null
          ? "Specifies an invalid Request-URI."
          : !context.IsWebSocketRequest
            ? "Not a WebSocket connection request."
            : !validateSecWebSocketKeyHeader (headers["Sec-WebSocket-Key"])
              ? "Includes an invalid Sec-WebSocket-Key header."
              : !validateSecWebSocketVersionClientHeader (headers["Sec-WebSocket-Version"])
                ? "Includes an invalid Sec-WebSocket-Version header."
                : CustomHandshakeRequestChecker (context);
 }
开发者ID:greeduomacro,项目名称:uomap-client,代码行数:14,代码来源:WebSocket.cs


示例6: init

 // As server
 private void init(WebSocketContext context)
 {
     _context = context;
       _uri = context.Path.ToUri ();
       _secure = context.IsSecureConnection;
       _client = false;
 }
开发者ID:kevleyski,项目名称:websocket-sharp,代码行数:8,代码来源:WebSocket.cs


示例7: checkIfValidHandshakeRequest

 // As server
 private string checkIfValidHandshakeRequest(WebSocketContext context)
 {
     var headers = context.Headers;
       return !context.IsWebSocketRequest
      ? "Not WebSocket connection request."
      : !validateHostHeader (headers ["Host"])
        ? "Invalid Host header."
        : !validateSecWebSocketKeyHeader (headers ["Sec-WebSocket-Key"])
          ? "Invalid Sec-WebSocket-Key header."
          : !validateSecWebSocketVersionClientHeader (headers ["Sec-WebSocket-Version"])
            ? "Invalid Sec-WebSocket-Version header."
            : CustomHandshakeRequestChecker (context);
 }
开发者ID:jijamw,项目名称:websocket-sharp,代码行数:14,代码来源:WebSocket.cs


示例8: Start

        internal void Start(WebSocketContext context, WebSocketSessionManager sessions)
        {
            if (_websocket != null) {
            _websocket.Log.Error ("This session has already been started.");
            context.WebSocket.Close (HttpStatusCode.ServiceUnavailable);

            return;
              }

              _context = context;
              _sessions = sessions;

              _websocket = context.WebSocket;
              _websocket.CustomHandshakeRequestChecker = checkIfValidConnectionRequest;
              _websocket.EmitOnPing = _emitOnPing;
              _websocket.IgnoreExtensions = _ignoreExtensions;
              _websocket.Protocol = _protocol;

              var waitTime = sessions.WaitTime;
              if (waitTime != _websocket.WaitTime)
            _websocket.WaitTime = waitTime;

              _websocket.OnOpen += onOpen;
              _websocket.OnMessage += onMessage;
              _websocket.OnError += onError;
              _websocket.OnClose += onClose;

              _websocket.ConnectAsServer ();
        }
开发者ID:GenMindu,项目名称:websocket-sharp,代码行数:29,代码来源:WebSocketBehavior.cs


示例9: Handle

 public override WebSocketPackageInfo Handle(IAppSession session, WebSocketContext context, IList<ArraySegment<byte>> data)
 {
     return new WebSocketPackageInfo(data, ServiceProvider.BinaryDataParser, ServiceProvider.StringParser);
 }
开发者ID:RocChing,项目名称:SuperSocket,代码行数:4,代码来源:BinaryHandler.cs


示例10: Parse

 public static RequestHandshake Parse(WebSocketContext context)
 {
     return new RequestHandshake {
     Headers         = context.Headers,
     HttpMethod      = "GET",
     RequestUri      = context.RequestUri,
     ProtocolVersion = HttpVersion.Version11
       };
 }
开发者ID:hjhome2000,项目名称:websocket-sharp,代码行数:9,代码来源:RequestHandshake.cs


示例11: StartSession

 internal void StartSession(WebSocketContext context)
 {
     var session = CreateSession ();
       session.Start (context, Sessions);
 }
开发者ID:hdczsf,项目名称:websocket-sharp,代码行数:5,代码来源:WebSocketServiceHost.cs


示例12: checkIfValidHandshakeRequest

 // As server
 private string checkIfValidHandshakeRequest(WebSocketContext context)
 {
     var headers = context.Headers;
       return !context.IsWebSocketRequest
      ? "Not WebSocket connection request."
      : !validateHostHeader (headers ["Host"])
        ? "Invalid Host header."
        : !validateSecWebSocketKeyHeader (headers ["Sec-WebSocket-Key"])
          ? "Invalid Sec-WebSocket-Key header."
          : !validateSecWebSocketVersionClientHeader (headers ["Sec-WebSocket-Version"])
            ? "Invalid Sec-WebSocket-Version header."
            : !validateCookies (context.CookieCollection, _cookies)
              ? "Invalid Cookies."
              : null;
 }
开发者ID:uken,项目名称:websocket-sharp,代码行数:16,代码来源:WebSocket.cs


示例13: Handle

 public abstract WebSocketPackageInfo Handle(IAppSession session, WebSocketContext context, IList<ArraySegment<byte>> data);
开发者ID:RocChing,项目名称:SuperSocket,代码行数:1,代码来源:OpHandlerBase.cs


示例14: checkHandshakeRequest

 private string checkHandshakeRequest(WebSocketContext context)
 {
     return _originValidator != null && !_originValidator (context.Origin)
      ? "Includes no Origin header, or it has an invalid value."
      : _cookiesValidator != null
        && !_cookiesValidator (context.CookieCollection, context.WebSocket.CookieCollection)
        ? "Includes no cookie, or an invalid cookie exists."
        : null;
 }
开发者ID:jogibear9988,项目名称:websocket-sharp,代码行数:9,代码来源:WebSocketBehavior.cs


示例15: StartSession

        /// <summary>
        /// Starts a new session to the WebSocket service using the specified <see cref="WebSocketContext"/>.
        /// </summary>
        /// <param name="context">
        /// A <see cref="WebSocketContext"/> that contains a WebSocket connection request objects.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="context"/> is <see langword="null"/>.
        /// </exception>
        internal void StartSession(WebSocketContext context)
        {
            if (context == null)
            throw new ArgumentNullException ("context");

              var session = CreateSession ();
              session.Start (context, Sessions);
        }
开发者ID:richardfeng,项目名称:UnitySocketIO-WebSocketSharp,代码行数:17,代码来源:WebSocketServiceHost.cs


示例16: checkIfValidConnectionRequest

 private string checkIfValidConnectionRequest(WebSocketContext context)
 {
     return _originValidator != null && !_originValidator (context.Origin)
      ? "Invalid Origin header."
      : _cookiesValidator != null &&
        !_cookiesValidator (context.CookieCollection, context.WebSocket.CookieCollection)
        ? "Invalid Cookies."
        : null;
 }
开发者ID:GenMindu,项目名称:websocket-sharp,代码行数:9,代码来源:WebSocketBehavior.cs


示例17: WebSocket

        // As server
        internal WebSocket(TcpListenerWebSocketContext context, string protocol, Logger logger)
        {
            _context = context;
              _protocol = protocol;
              _logger = logger;

              _closeContext = context.Close;
              _secure = context.IsSecureConnection;
              _stream = context.Stream;

              init ();
        }
开发者ID:MylesBell,项目名称:Unity,代码行数:13,代码来源:WebSocket.cs


示例18: Bind

        internal void Bind(WebSocketContext context, WebSocketServiceManager sessions)
        {
            if (IsBound)
            return;

              _context = context;
              _sessions = sessions;
              _websocket = context.WebSocket;
              _websocket.CookiesValidation = ValidateCookies;
              _websocket.OnOpen += onOpen;
              _websocket.OnMessage += onMessage;
              _websocket.OnError += onError;
              _websocket.OnClose += onClose;

              IsBound = true;
        }
开发者ID:shinyboy,项目名称:websocket-sharp,代码行数:16,代码来源:WebSocketService.cs


示例19: Start

        internal void Start(WebSocketContext context, WebSocketSessionManager sessions)
        {
            _context = context;
              _sessions = sessions;

              _websocket = context.WebSocket;
              _websocket.Protocol = _protocol;
              _websocket.CookiesValidation = ValidateCookies;

              _websocket.OnOpen += onOpen;
              _websocket.OnMessage += onMessage;
              _websocket.OnError += onError;
              _websocket.OnClose += onClose;

              _websocket.ConnectAsServer ();
        }
开发者ID:uken,项目名称:websocket-sharp,代码行数:16,代码来源:WebSocketService.cs


示例20: WebSocket

        // As server
        internal WebSocket(TcpListenerWebSocketContext context, Logger logger)
        {
            _context = context;
              _logger = logger;

              _closeContext = context.Close;
              _secure = context.IsSecureConnection;
              _stream = context.Stream;
              _uri = context.Path.ToUri ();

              init ();
        }
开发者ID:jijamw,项目名称:websocket-sharp,代码行数:13,代码来源:WebSocket.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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