Dev con kolkata 2012 websockets

11
Developer Conference 2012 MICROSOFT USER GROUP KOLKATA

Transcript of Dev con kolkata 2012 websockets

Page 1: Dev con kolkata 2012   websockets

Developer Conference 2012 MICROSOFT USER GROUP KOLKATA

Page 2: Dev con kolkata 2012   websockets

Web Sockets – Building Real Time App for Web

Sankarsan Bose

26th May , 2012

Page 3: Dev con kolkata 2012   websockets

The Real Time “Web”

- Real time information delivery - Instant updates, searches - Facebook, Twitter.. Etc.

- HTTP essentially is still stateless - Technologies/Techniques we have to support the same are

- AJAX (XMLHttpRequest) - Long Polling - Comet

Real Time Web

Technologies

Challenges

- Clients polling for data, ideally where server should broadcast - Overhead of

Multiple TCP connections Same/similar header data being transferred each time over the wire Customized ways to tracking or correlating requests and responses.

Page 4: Dev con kolkata 2012   websockets

WebSockets - Introduction

- WebSockets is a protocol for two-way communication between client and server

- Uses a single TCP connection.

- Takes away overhead of

- Multiple TCP connections

- Same/similar header data being transferred each time over the wire

- Customized ways to tracking or correlating requests and responses.

- Part of HTML5 initiative

- WebSocket Specs has

- Protocol Specification

- API Specification

- Supported by Google Chrome, Firefox,IE 10

- Server side support by Jetty,Node.js (Socket.io), IIS 8.0 (on Windows 8)

WebSockets

Page 5: Dev con kolkata 2012   websockets

WebSockets with IIS 8.0 and IE10

Let’s go to the code…

Page 6: Dev con kolkata 2012   websockets

WebSocket - API

Client (Browser)

Server

Establish Connection

var ws= new WebSocket("ws://www.websockets.org");

Connection Established

OnOpen event fired

Send method called

Data Sent to Server

Data Sent from Server

OnMessage event is fired

Close method is called

Close Connection

Connection Closed

OnClose Event is fired

Page 7: Dev con kolkata 2012   websockets

WebSockets Protocol

Client (Browser)

Server

Send HTTP Request for protocol switch/upgrade

- If server understands WebSocket protocol - It issues HTTP 101 - There is a protocol switch - HTTP connection is no longer used - WebSocket connection takes over the

underlying TCP connection

Page 9: Dev con kolkata 2012   websockets

Thanks Everybody, For Your Time.

Happy Coding…..Enjoy Learning..

Page 10: Dev con kolkata 2012   websockets

Speaker Details/Contact

- http://twitter.com/sankarsan

- http://sankarsan.wordpress.com

- http://codingndesign.com

- http://sankarsanbose.com