void AcceptConnection() { const string fmt = "HTTP/1.1 101 Switching Protocols\r\n" + "Upgrade: websocket\r\n" + "Connection: Upgrade\r\n" + "Sec-WebSocket-Accept: {0}\r\n" + "Sec-WebSocket-Protocol: ClassiCube\r\n" + "\r\n"; string key = verKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; SHA1 sha = SHA1.Create(); byte[] raw = sha.ComputeHash(Encoding.ASCII.GetBytes(key)); string headers = String.Format(fmt, Convert.ToBase64String(raw)); s.Send(Encoding.ASCII.GetBytes(headers), false); readingHeaders = false; }
protected override void SendRaw(byte[] data, SendFlags flags) { s.Send(data, flags); }
public void Send(byte[] data) { socket.Send(data, SendFlags.None); }
protected override void SendRaw(byte[] data, bool sync) { s.Send(data, sync); }