Top Banner
Realtime Web Applications wit ExpressJS Hüseyin BABAL Software Developer, CSM @Sony Eurasia
28

Realtime web applications with ExpressJS and SocketIO

Aug 20, 2015

Download

Technology

Hüseyin BABAL
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Realtime web applications with ExpressJS and SocketIO

Realtime Web Applications wit ExpressJS

Hüseyin BABALSoftware Developer, CSM

@Sony Eurasia

Page 2: Realtime web applications with ExpressJS and SocketIO

A Scenario...

Page 3: Realtime web applications with ExpressJS and SocketIO

Plane status board…

Updating board on every flight

Check flight status for every second?

Let’s code that board software...

Page 4: Realtime web applications with ExpressJS and SocketIO
Page 5: Realtime web applications with ExpressJS and SocketIO

Good Code, but this is something like...

Page 6: Realtime web applications with ExpressJS and SocketIO
Page 7: Realtime web applications with ExpressJS and SocketIO

Yeah, client side server bombing...

Page 8: Realtime web applications with ExpressJS and SocketIO

It would be better if server side inform client on any update...

Page 9: Realtime web applications with ExpressJS and SocketIO
Page 10: Realtime web applications with ExpressJS and SocketIO

What is SocketIO?

Page 11: Realtime web applications with ExpressJS and SocketIO

● Care-Free realtime 100% Javascript● Cross-Browser and mobile device● Wrapper for the Websocket● Learnboost

Page 12: Realtime web applications with ExpressJS and SocketIO

Go back to origin...

Page 13: Realtime web applications with ExpressJS and SocketIO

Websocket?● Full-duplex comm. channels over TCP● Only its handshake interpreted by HTTP servers● Push server data to client browser● 80 port and no firewall prevent

Page 14: Realtime web applications with ExpressJS and SocketIO

Handshake

Page 15: Realtime web applications with ExpressJS and SocketIO
Page 16: Realtime web applications with ExpressJS and SocketIO

Clients sends base64 encoded string

Server appends a magic string to it and encrypt SHA-1 after then base64

Example...

Page 17: Realtime web applications with ExpressJS and SocketIO

Client: x3JJHMbDL1EzLkh9GBhXDw==

Server: x3JJHMbDL1EzLkh9GBhXDw==258EAFA5-E914-47DA-95CA-C5AB0DC85B11 then SHA-1.

base64(above appended string) = HSmrc0sMlYUkAGmm5OPpG2HaGWk=

Page 18: Realtime web applications with ExpressJS and SocketIO

In SocketIO, you don’t need to know all this

stuffs

Page 19: Realtime web applications with ExpressJS and SocketIO

Send / Receive Events

Page 20: Realtime web applications with ExpressJS and SocketIO

Store client data

Page 21: Realtime web applications with ExpressJS and SocketIO

Namespace

Page 22: Realtime web applications with ExpressJS and SocketIO

Volatile Messaging

Page 23: Realtime web applications with ExpressJS and SocketIO

Acknowledgement

Page 24: Realtime web applications with ExpressJS and SocketIO

Broadcasting

Page 25: Realtime web applications with ExpressJS and SocketIO

QuickiesExpressJS https://github.com/visionmedia/express

SocketIO https://github.com/LearnBoost/socket.io

Learnboost https://github.com/LearnBoost

Websockets http://en.wikipedia.org/wiki/WebSocket

Button Click Game http://btnclick.herokuapp.com/signin

Heroku Websockets https://blog.heroku.com/archives/2013/10/8/websockets-public-beta

Page 26: Realtime web applications with ExpressJS and SocketIO

Mobile?Will Be Demonstrated

on Next BBS

Page 27: Realtime web applications with ExpressJS and SocketIO
Page 28: Realtime web applications with ExpressJS and SocketIO

Thanks