Slide 1

Slide 1 text

Full-duplex cloud app with WebSocket

Slide 2

Slide 2 text

@luka_bernardi Luca Bernardi

Slide 3

Slide 3 text

“Everything goes through an API, 
 we are functioning 
 with cloud app” “Mobile is not Different” https://vimeo.com/61044805

Slide 4

Slide 4 text

Document vs. Stream Paradigms

Slide 5

Slide 5 text

Document Paradigm Built around request/response 
 paradigm of HTTP

Slide 6

Slide 6 text

Stream Paradigm Instantly update your content as things happens

Slide 7

Slide 7 text

What we are going to build

Slide 8

Slide 8 text

Hey, what about old good BSD socket?

Slide 9

Slide 9 text

“No App is an island” Not suitable for web applications

Slide 10

Slide 10 text

Abstraction Wouldn’t be nice to have an 
 event-based layer of abstraction?

Slide 11

Slide 11 text

Abusing HTTP Polling Long Polling Streaming

Slide 12

Slide 12 text

Meet WebSocket ! Independent TCP-based protocol that enables bidirectional, message-oriented streaming of text and binary data between client and server.

Slide 13

Slide 13 text

Server side [JS/Node.js] Socket.io (http://socket.io) [Python] Tornado (http:// www.tornadoweb.org) [Ruby] em-websocket (https:// github.com/igrigorik/em-websocket) [Objective-C] RockemSockem (https:// github.com/joshaber/RockemSockem) http://www.pusher.com http://www.pubnub.com https://www.hydna.com Comprehensive of realtime web technologies: https://github.com/leggetter/realtime-web-technologies-guide/blob/master/guide.md Self-Hosted Hosted

Slide 14

Slide 14 text

Socket.io Socket.io > WebSocket Abstract the transport mechanism

Slide 15

Slide 15 text

Event/Message based

Slide 16

Slide 16 text

Heartbeat By sending a heartbeat at a predetermined interval the client informs the server 
 that it's still there.

Slide 17

Slide 17 text

Rooms Partitioning of the connected clients.

Slide 18

Slide 18 text

Show us some code!

Slide 19

Slide 19 text

Server Code

Slide 20

Slide 20 text

Client libraries AZSocketIO (https://github.com/pashields/AZSocketIO) Socket.IO-objc (https://github.com/pkyeck/socket.IO-objc)

Slide 21

Slide 21 text

Client Code

Slide 22

Slide 22 text

Use Case Chat / Messaging Real-time geolocation Stream of event/news Real-time collaboration Games

Slide 23

Slide 23 text

Think different your API Photo by Héctor García (http://www.flickr.com/photos/torek/7109339349/)

Slide 24

Slide 24 text

Question?