Dev con kolkata 2012 websockets

Post on 17-May-2015

681 views 0 download

Tags:

Transcript of Dev con kolkata 2012 websockets

Developer Conference 2012 MICROSOFT USER GROUP KOLKATA

Web Sockets – Building Real Time App for Web

Sankarsan Bose

26th May , 2012

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.

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

WebSockets with IIS 8.0 and IE10

Let’s go to the code…

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

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

Thanks Everybody, For Your Time.

Happy Coding…..Enjoy Learning..

Speaker Details/Contact

- http://twitter.com/sankarsan

- http://sankarsan.wordpress.com

- http://codingndesign.com

- http://sankarsanbose.com