Listen

Description

Discussion

Pushing info to clients

Long Polling

Client sends request to server, waits for response or timeouts (Loop)
Can send and receive information, but not full-duplex
iOS Implementation

NSURLConnection sendSynchronousRequest

Common uses

Fallback from Websockets and SSE when streams are unreliable or impractical

HTTP Streams

Can only push information to your client
If you need to send info back to server use standard rest approach
Transported over simple HTTP
Built in support for re-connection and event-id
iOS Implementation

Server Sent Events (SSE)
NSURLSession, NSInputStream, NSSteamEvent
Setup the connection
Implement code to handleEvents from the input stream

Common uses

Stock ticker streaming
“Status” feed updating
Push Notifications

Websockets

Designed to overcome many of the pitfalls/shortcomings described in RFC 6202
Standardized by IETF (Internet Engineering Task Force) in 2011
Can send and receive information (full-duplex pipe)
Protocol based on TCP
Uses HTTP only for initial handshake, while leveraging existing HTTP infrastructure
iOS Implementation

CFStreamCreatePairWithSocketToHost takes url, read and write stream
Cast read and write stream to NSInputStream and NSOutputStream, respectively
Set delegate for input and output streams
Schedule both in a run loop (Can do without but will block the execution of other code)
Open connection
Write code to handleEvents from the input stream
Implement message sending via the output stream

Server considerations

Not as easy to get started with as a generic web server
Buy one, borrow one or build one

Common uses

Chat
Player vs. Player games
Real time interactions

Popular Abstractions/Frameworks

TRVSEventSource from Travis Jeffery
SignalR from Microsoft

At-a-glance Comparison

Websockets
SSE
Long Polling

Client Performance
Best
Best
Worst

Server Performance
Best
Worst
Worst

Complexity
Highest
Lowest
Mid

When to Use
2-way messaging
Push to Client
Just getting started

Picks

Darryl

Proportional Spacing with Auto Layout

John

Google Cloud Vision API Detects types of images, landmarks, recognizes text, does image sentiment analysis and can even detect “inappropriate content”
Agile and Beyond 2016 May 5-6 in Ypsilanti, MI

Alternative show title suggestions

Uncanny valley
The cooker's always on
Canonical Framing Technique