Real-TimeWeb APIs
Ryan J. McDonough
@damnhandy | http://damnhandy.com
Options
Protocols
• Long-Polling
• PubSubHubbub
• WebHooks
• WebSockets
• Server-Sent Events
Services
• Pusher
• Kaazing
• PubNub
Promising Directions
• PubSubHubbub
• Server-Sent Events (SSE)
• WebSockets + “Something Else”
PubSubHubbub
WebSockets
• STOMP +WebSockets is an interesting idea
• No ideal way for indicating the sub-protocol used by
theWebSocket
• No way to express what media type is coming over the
wire
• Not sure bi-direction communication is necessary
Server-Sent Events
Connection: keep-alive
Content-Type: text/event-stream
Date: Sat, 21 Sep 2013 13:31:59 GMT
data: {"msg": "First message"}nn
event: userlogonn
data: {"username": "John123"}nn
event: updaten
data: {"username": "John123", "emotion": "happy"}nn
WhatWould Browser Do?
<script>
var source = new EventSource(’/updates');
source.addEventListener('add',
addHandler,
false);
</script>
WhatWould PSHB Do?
Link: <http://example.com/events>;
rel=”hub";
Ideas: Links for SSE
Link: <http://example.com/events>; rel="notifications";
type="text/event-stream;data='application/ld+json'";
Links forWebSockets +
“Something”
Link: <ws://example.com/events>;
rel=”websocket/something";
type=“application/ld+json";

Real-Time Web APIs

Editor's Notes

  • #8 The browser typically gets code