Exemple #1
0
        public bool TryHandshake(WebSocketContext context, out IWebSocketReceiveFilter filter)
        {
            var responseBuilder = new StringBuilder();

            responseBuilder.AppendWithCrCf("HTTP/1.1 400 Bad Request");
            responseBuilder.AppendWithCrCf("Upgrade: WebSocket");
            responseBuilder.AppendWithCrCf("Connection: Upgrade");
            responseBuilder.AppendWithCrCf("Sec-WebSocket-Version: " + string.Join(", ", m_Versions.Select(i => i.ToString()).ToArray()));
            responseBuilder.AppendWithCrCf();

            var switchResponse = Encoding.UTF8.GetBytes(responseBuilder.ToString());

            filter = new MultipleProtocolSwitchReceiveFilter(switchResponse);

            return(true);
        }
 public bool TryHandshake(WebSocketContext context, out IWebSocketReceiveFilter filter)
 {
     filter = new MultipleProtocolSwitchReceiveFilter(m_SwitchResponse);
     return(true);
 }