Introduction to WebSockets

A Workshop

Agenda

  1. Short presentation: intro to Websockets
  2. Overview of demo code
  3. Q&A, and maybe some livecoding

Jack Lawson

@ajacksified on twitter & github

Engineer at Airbnb ps: we're hiring

Web Game Hobbyist

Jack Lawson

Gaming?

Good time for gaming in the browser

  • Audio API
  • WebGL, Canvas
  • Pointer lock
  • Good browsers to implement it all
  • (WebSockets)

But Also, Other Uses

  • Airbnb - Internal Tools
  • CMS - collaborative editing
  • Support chats
  • Live Analytics

But, These Things Existed Before WebSockets

  • Oracleâ„¢ Java® Applets
  • Flash and Silverlight applications
  • Comet connections
  • Ajax polling (my personal favorite)
  • <meta http-equiv="refresh" content="5">

WebSockets Are...

WebSockets Are Bidirectional & Full Duplex

The client is connected to the server, and the server is connected to the client, and can send data at the same time over TCP.

WebSockets Are Secure

WebSocket connections are secured with a handshake and masking, and also support SSL.

WebSockets Are Simple


socket = new WebSocket("ws://echo.websocket.org/");
          

Resources

Let's Do a WebSocket

Project: github.com/ajacksified/websockets-workshop

brew install node OSX

nodejs.org Windows

apt-get install node Ubuntu

npm start, then visit localhost:3333