Programming WebSockets Presentation

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

ProgrammingWebSocketsSeanSullivanOSCONJuly22,2010AboutmeWebapplicationdevelopersHTML5!improvedJavaScriptimplementations!WebSockets!WebSockets?WebSocketsatechnologythatenablesbidirectionalcommunicationbetweenwebbrowsersandserver-sideprocesses“TCPfortheweb”PushtechnologyCometWebSocketsAJAXClient-servercommunicationExampleMulti-playergameRockPaperScissorsLizardSpockSpecifications•WebSocketsAPI•WebSocketsprotocolJavaScriptexamplevarsock=newWebSocket('wss://);sock.onopen=function(evt){alert(‘open!’);};sock.onmessage=function(evt){alert(‘Message:‘+evt.data);}sock.onerror=function(evt){alert(‘error!’);};sock.onclose=function(evt){alert(‘closed!’);}sock.send(“HelloOSCON!”);sock.close();WebSocketURLs•ws://example.com/demo•wss://example.com/demoeventhandlers•onopen•onmessage•onerror•oncloseSpecifications•WebSocketsAPI•WebSocketsprotocol51pages!WebSocketsprotocol•ports80and443•HTTP“upgrade”handshakeBrowserrequestGET/testHTTP/1.1Upgrade:WebSocketConnection:UpgradeOrigin:::WebSocketConnection:UpgradeServer:FooServer/1.5WebSocket-Location:ws://::0Date:Fri,08May201007:23:58GMTtheWebSocketnetworkprotocolisstillchanging!Protocolevolution•draft-hixie-thewebsocketprotocol-75•draft-hixie-thewebsocketprotocol-76•draft-ietf-hybi-thewebsocketprotocol-00DevelopersshouldbeawarethatstartingfromWebKitnightlybuildr59903andChrome6.0.414.0(r47952),theclientwilltalktoaserverusing-76versionoftheprotocol,soitwillfailtoopenWebSocketconnectionswithaWebSocketserverbasedondraft-hixie-thewebsocketprotocol-75.Since-75versionoftheprotocolisobsoletedandnolongersupportedinfutureversionofbrowsers,tosupportnewclientsyouneedtoupdatetheserverimplementation.(NotethatChrome5uses-75versionofprotocol)source::•GoogleChrome4.0.249.0andhigher•Safari5.0•Firefox:4.0beta1•InternetExplorer9:TBDWebSocketsontheserver-side=47485Nostandardserver-sideJavaAPIOtherJavaprojects•Glassfish/Grizzly•jWebSocket•JBossNetty•CauchoResinConclusion•WebSocketsisanemergingtechnology•JavaScriptAPIiseasytolearn•JavaScriptAPIiseasytouse•Lotsofchoicesontheserver-sideThankyouBonusslides!jQuery•••Flashsockets•Silverlightduplexservices•Comet•WebSocketsWebSocketsandHTML5“Atlastweek'stelecon,whilediscussingISSUE-64,itwasproposedthatwedeclareWebSocket(bothAPIandprotocol)outofscopeforHTML5.SincetheAPIandprotocolhavebeeninseparatespecsforsometime,thiswouldhavenoimmediatematerialeffect.However,itwouldpreventusfromputtingWebSocketbackinthemainHTML5specinthefuture,unlessnewinformationcametolightwhichwouldallowustoreopenthedecision.”September92009“Sincetherewasnoobjection,theresolutionhasnowpassed.”September232009•same-originpolicyapplies•usewss://ifyouwantasecureconnectionDemo:HTML5+WebSockets

1 / 57
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功