Anzeige

Web sockets

10. Dec 2015
Anzeige

Más contenido relacionado

Anzeige

Web sockets

  1. WebSockets By Bodo Kaiser
  2. Preface
  3. Specs Response Request Request Socket
  4. Upgrade I Request Response HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept <accept> Sec-WebSocket-Protocol: <prot1> GET /<endpoint> HTTP 1.1 Host: example.org Upgrade: websocket Connection: Upgrade Origin: example.org Sec-WebSocket-Accept <key> Sec-WebSocket-Version: 13 Sec-WebSocket-Protocol: <prot1>
  5. Upgrade II Key dGhlIHNhbXBsZSBub25jZQ== GUID 258EAFA5-E914-47DA-95CA-C5AB0DC85B11 Concat Hash sha1 Encode base64 Accept s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
  6. Frame I Head Payload RSV, Opcode 1 Byte Masked, Length I 1 Byte Length II 2 Byte Masking 4 Byte Length III 8 Byte Opcodes: Continuation (0x00), Text (0x01), Binary (0x02), Close (0x08), Ping (0x09), Pong (0x0a)
  7. Frame II Length 7 Bit Length I < 0x7e Length II = 0x7e Length III = 0x7f Masked for (var i = 0; i < b.length; i++) { b[i] = b[i] ^ m[i % 4] }
  8. Streams function Incoming() { Transform.call(this) } Inherits(Incoming, Transform) Transform.prototype._read = function(chunk, encoding, callback) { if (!this.header) { // parse head } if (this.header.masked) { // unmask payload } callback(null, chunk) }
  9. Experience
  10. Thank You Bodo Kaiser <i@bodokaiser.io>
Anzeige