2. Getting Data to Clients
Request + Response
1. Client Requests Data to a specific endpoint
2. Server Responds with Data
• Pros: simultaneous, easily trackable
• Cons: always a one-way transaction, can’t push to client
Step 1
Client Requests `/route`
Server Responds with `some data`
Step 2
3. Getting Data to Clients
Polling
1. Client Requests Data
2. Server Responds with Data,
• request again after a set time period
• Pros: achieves push-like functionality
• Cons: still initiated by client, wasteful
Step 1 , 3 , …
Client Requests `/route`
Server Responds with `some data`
Step 2 , 4 , …
4. Getting Data to Clients
Long Polling
• Client Requests Data ; Server HOLDS the request until some trigger to Respond back
• After response, initiate request again
• Pros: achieves push-like functionality
• with less waste than regular polling
• Cons: still initiated by client, some overhead
Step 1
Client Requests `/route`
Server Responds with `some data`
Step 3
Step 2
Server holds request until a trigger
5. Getting Data to Clients
WebSockets
• Client initiates a handshake with socket server
• After connection, client AND server can send messages back and
forth
• Pros: achieves TRUE push
• Cons: more setup than HTTP, browser support
6. Getting Data to Clients
socket.io
• Provides server PUSH support by leveraging WebSockets if the client
supports it, while providing fallbacks to Long-Polling or other
• Abstracts away the specifics into a clean API that clients can connect,
disconnect, and send & receive messages
• Alternatives: FireBase (full service rather than transfer), Faye, +more
7. socket.io & ember.js
• Ember doesn’t come with any websocket support or
integration out of the box, however
• Ember integration with socket.io is quick and easy
• especially with Ember-CLI
9. What I didn’t cover
• Authentication/Authorization
• Security
• Multiple namespaces
• Production multiple nodes & distribution
• Refactoring for general purpose