WebSockets in nodejs

1,070 views

Published on

Talk from berlinjs 18. April 2013

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,070
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
23
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

WebSockets in nodejs

  1. 1. How to implement WebSockets in nodejsFreitag, 19. April 13
  2. 2. Why actually implement a protocol? bad support want to learn more too much timeFreitag, 19. April 13
  3. 3. WebSocket Overview http upgrade data framingFreitag, 19. April 13
  4. 4. http upgrade Request GET ws://localhost:3000/ HTTP/1.1 Host: localhost:3000 Origin: http://localhost:3000 Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: balUGY40R1lyHPJZf3XHqQ== Sec-WebSocket-Extensions: x-webkit-deflate-frame Sec-WebSocket-Protocol: chat Sec-WebSocket-Version: 13 Response HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: GCPOtLmN+iCXPREPmHfgCKsCllU= Sec-WebSocket-Extensions: x-webkit-deflate-frame Sec-WebSocket-Protocol: chat Sec-WebSocket-Version: 13Freitag, 19. April 13
  5. 5. data framing unmasked text frame containing „Hello“ 10000001 0x81 FIN: Boolean RSV1: Boolean 00000101 0x05 RSV2: Boolean RSV3: Boolean 01001000 0x48 H OPCODE: Number MASK: Boolean 01100101 0x65 e LENGTH: Number MASKING: Buffer 01101100 0x6c l PAYLOAD: Buffer 01101100 0x6c l 01101111 0x6c oFreitag, 19. April 13
  6. 6. Freitag, 19. April 13
  7. 7. Architecture: First Take... WebSocketServer WebSocketClient WebSocketUpgrade WebSocketBase WebSocket WebSocketFrame SocketFreitag, 19. April 13
  8. 8. Freitag, 19. April 13
  9. 9. Architecture: Second Take WebSocketServer WebSocketUpgrade WebSocketSocket Incoming Outgoing WebSocketCore WebSocketParser SocketFreitag, 19. April 13
  10. 10. End only use ws for chat-like use-cases use streams where you can don`t worry v8 is fast enough https://github.com/bodokaiser/node-websocketsFreitag, 19. April 13

×