codecamp iasi-26 nov 2011 - html 5 websockets

19
html 5 websockets Florin Cardașim, twitter.com/@cardasim Endava 26 nov 2011

Upload: florin-cardasim

Post on 12-May-2015

1.431 views

Category:

Technology


1 download

DESCRIPTION

http://codecamp.ro/post/2011/12/02/Codecamp-de-toamna-la-Iasi-2011-dupa-eveniment.aspx

TRANSCRIPT

Page 1: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

html 5 websocketsFlorin Cardașim, twitter.com/@cardasimEndava

26 nov 2011

Page 2: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Agenda

Real-time web

Demo: long polling

SSE, WebSockets

Demo: WebSockets in Windows 8, ASP.NET & WCF 4.5

Q&A

Page 3: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

How do we implement real-time web?

periodic ajax pollingcomet/long polling/http streaming …

flash/javafx/silverlight

html5 server-sent eventshtml5 web sockets

Page 4: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Pollingconnectno messageconnectno message

eventconnectevent

Browser Server

connectno messageconnectno message

eventconnectevent

Page 5: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Polling

No real-time user experienceWasted bandwidth, most requests return no data

Frequent polling determine high server loads

Page 6: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Comet/long polling

connect

eventevent

Browser Server

event

wait

connectwait

eventconnect

wait

Page 7: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Comet/long polling

Real-time user experience

High number of clients determines high pressure on bandwidth, memory, threads/processes

DEMO

Page 8: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Html5 server-sent eventsopen event stream

eventevent

Browser Server

event

Open

HTTP co

nn

ectio

n

event

eventevent

<EventSource>

onmessageonmessageonmessage

Page 9: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Html5 server-sent events

Simulates a server push channel over HTTP

Unidirectional, from server to browserStandardizes some form of Comet/http streaming

New html tag: <EventSource>New mime type: text/event-stream

Page 10: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Html5 WebSocketsClient/Browser

ServerGET /text HTTP/1.1Upgrade: WebSocket Connection: UpgradeHost: www.websocket.org ...

HTTP/1.1 101 WebSocket Protocol HandshakeUpgrade: WebSocket ...

TCP comm channel

Full duplex, bidirectional

Page 11: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Html5 WebSocketsFull duplex, bidirectionalSingle TCP socketStandard ports: http/80, https/443Bandwidth savingsHigher scalability comparing with CometIn&outside of browser

IETF WebSockets Communication protocol

W3C WebSockets API

Page 12: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Server side supportSocket.IO (node.js) Jetty (Java)Ruby/EventMachinePython/TwistedWindows 8, IIS 8, ASP.NET-WCF 4.5

… others

Socket.IO FallbacksAdobe Flash Socket

AJAX Long PollingAJAX Multipart Streaming

Forever iFrame JSONP Polling

http://socket.io/

Page 13: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Browser support

Page 14: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

DEMO: WebSockets @Microsoft

ASP.NET 4.5WCF 4.5

Windows 8 Developer PreviewIIS 8ASP.NET 4.5WCF 4.5IE 10, Chrome

Page 15: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

WebSockets @Microsoft

http.sys

IIS (iiswsock.dll)

ASP.NET HTTP Pipeline

System.Net.WebSockets

HttpListener

WCF WebSocket transport

WCF high level abstractions

Your code!

ASP.NET high level abstractions

Page 16: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Referenceswww.websocket.orgwww.paulbatum.com www.kaazing.me www.html5labs.com www.buildwindows.com www.google.com/search?q=websocket

Page 17: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Q&A

Page 18: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

Please fill your evaluation form

Thank you!

Florin Cardașim, twitter.com/@cardasim Endava26 nov 2011

Page 19: Codecamp Iasi-26 nov 2011 - Html 5 WebSockets

WebSockets vs Polling bandwidth

http://websocket.org/quantum.html