private void SendNegotiationResponse(WebSocketHandshake handshake, StreamWriter writer)
{
writer.Write("HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\n");
if (handshake.Response.Cookies.Count > 0)
{
foreach (var cookie in handshake.Response.Cookies)
{
writer.Write("Set-Cookie: ");
writer.Write(cookie.ToString());
writer.Write("\r\n");
}
}
writer.Write("Sec-WebSocket-Accept: ");
writer.Write(handshake.GenerateHandshake());
if (handshake.Request.Headers.HeaderNames.Contains(WebSocketHeaders.Protocol))
{
writer.Write("\r\nSec-WebSocket-Protocol: ");
writer.Write(handshake.Response.WebSocketProtocol);
}
WriteHandshakeCookies(handshake, writer);
writer.Write("\r\n\r\n");
}