Title Text

Intro

Why WSS and SSE?

Dragons vs. Unicorns

2016 NKO Winner

http://dragons.gomagames.com

The Gauntlet

RPG Hacking Simulation

https://the-gauntlet.gomagames.com

Server-Sent Events

WSS Frame

Data Format

Basic HTTP

for contrast

Protocol Design

  1. [CLIENT] Establish connection to server
  2. [CLIENT] SEND HTTP Request
  3. [SERVER] SEND HTTP Response
  4. [SERVER] CLOSE connection
HTTP Request
HEADERS
BODY

CLIENT

HTTP Response
HEADERS
BODY

SERVER

Live code HTTP

Open connection

Send Request

GET / HTTP/1.1

Receive Response

Connection Closed

CLIENT

SERVER

Receive Request

Send Response

HTTP/1.1 200 OK

Close Connection

Short Examples

  • nc-http.sh
  • node-socket.js
  • node-http.js
  • node-bidi.js
  • node-broadcast.js

What would we do if we want to update the ui with current info from the server using HTTP?

Polling

while true

do

curl localhost:3000/api/game-events

sleep 5

done

Live code WSS

Debug WSS

Slack WSS

Caveats

Live code SSE

Debug SSE

Caveats

WSS OP Payloads

Messages in Dragons vs. Unicorns

Abstractions and Alternatives

Colyseus

PubSub

Protobufs

Protocol Buffers

Discussion

  • Other wss abstractions worth looking into?
  • Have you run into issues using wss?
  • Do you see benefits or use cases of SSE ?
  • Anything new on the horizon that solves a similar problem?

WSS and SSE

By Jon Borgonia

WSS and SSE

Real-time updates with Websockets and Server-Sent Events @ SeattleJSHackers

  • 1,161