ALE.Tcp.WebSocketHandshake.GetSecKey C# (CSharp) Метод

GetSecKey() публичный статический Метод

public static GetSecKey ( string clientHandshake ) : string
clientHandshake string
Результат string
        public static string GetSecKey(string clientHandshake)
        {
            var regSecKey = new Regex(@"Sec-WebSocket-Key: (.*?)\r\n");
            var match = regSecKey.Match(clientHandshake);
            if (match == null) return String.Empty;
            return match.Groups[1].Value;
        }

Usage Example

Пример #1
0
        private void SendHandshake(byte[] buffer, int bytesRead)
        {
            string text = Encoding.GetString(buffer, 0, bytesRead);

            ClientHandshake = text;
            string secKey = WebSocketHandshake.GetSecKey(ClientHandshake);

            SendUnencoded(WebSocketHandshake.GetHandshake(Encoding, secKey, Server.IP, Server.Port, Server.Origin),
                          ex =>
            {
                if (ex != null)
                {
                    EventLoop.Pend(() => Server.Callback(ex, null));
                }
                BeginRead();
                EventLoop.Pend(() => Server.Callback(null, this));
            });
        }