安卓下的socket.io息屏之后会不会断开连接
\u8bf7\u95ee\u5b89\u53537.1.1\u662f\u4e0d\u662f\u90fd\u6709\u606f\u5c4f\u60c5\u51b5\u4e0bwifi\uff0c\u6570\u636e\u8fde\u63a5\u6682\u505c\u4ee5\u53ca\u8f85\u52a9\u529f\u80fd\u81ea\u52a8\u5173\u95ed\u7684\u60c5\u51b5\u554a\u4e0d\u662f\uff0c\u8fd9\u5e94\u8be5\u662f\u7701\u7535\u6a21\u5f0f\u4e4b\u7c7b\u7684\u8bbe\u7f6e\u81ea\u52a8\u5173\u6389\u7684\u3002
\u53ef\u4ee5\u662f\u957f\u8fde\u63a5\u3002
\u5173\u4e8esocket.io\uff1a
\u6d4f\u89c8\u5668\u867d\u7136\u4e5f\u5c5e\u4e8e\u5ba2\u6237\u7aef\u7684\u4e00\u79cd\uff0c\u4f46\u4ec5\u652f\u6301\u201c\u5355\u5de5\u201d\u7684 HTTP \u901a\u8baf\u3002\u6709\u89c1\u53ca\u6b64\uff0cHTML5 \u65b0\u89c4\u8303\u4e2d\u63a8\u51fa\u4e86\u57fa\u4e8e\u6d4f\u89c8\u5668\u7684 WebSocket\uff0c\u5f00\u53d1\u4e86\u5e95\u5c42\u7684\u63a5\u53e3\uff0c\u5141\u8bb8\u7528\u6237\u80fd\u8fdb\u884c \u66f4\u5f3a\u5927\u7684\u64cd\u4f5c\uff0c\u8d85\u8d8a\u4ee5\u5f80\u7684 XHR\u3002\u7528\u6237\u65e0\u987b\u7b2c\u4e09\u65b9\u6846\u67b6\u5c31\u53ef\u4ee5\u76f4\u63a5\u4e0e Node TCP \u670d\u52a1\u5668 \u8fdb\u884c Socket \u901a\u8baf\u3002
\u4f46\u53c8\u8981\u8ba4\u6e05\u4e00\u4e2a\u4e8b\u5b9e\uff0c\u4e0d\u662f\u6bcf\u4e2a\u6d4f\u89c8\u5668\u90fd\u53ef\u4ee5\u987a\u5229\u652f\u6301 WebSocket \u7684\u3002\u4e8e\u662f Socket.IO \uff08http://socket.io\uff09\u51fa\u73b0\u4e86\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e0d\u652f\u6301 WebSocket \u65f6\u5019\u7684\u964d\u7ea7\u652f\u6301\uff0c\u540c\u65f6\u4f7f\u5f97\u4e00\u4e9b\u65e7\u7248\u672c\u7684\u6d4f\u89c8\u5668\u4e5f\u53ef\u4ee5\u201c\u5168\u53cc\u5de5\u201d\u5730\u5de5\u4f5c\u3002\u4f18\u5148\u4f7f\u7528\u7684\u987a\u5e8f\u5982\u4e0b\uff1a
WebSocket
Socket over Flash API
XHR Polling \u957f\u8fde\u63a5
XHR Multipart Streaming
Forever Iframe
JSONP Polling
\u4ee5\u4e0a\u9009\u62e9XHR Polling \u5c31\u53ef\u4ee5\u4fdd\u6301\u957f\u8fde\u63a5\u4e86\u3002
绛旓細鍙互鏄暱杩炴帴銆傚叧浜socket.io锛氭祻瑙堝櫒铏界劧涔熷睘浜庡鎴风鐨勪竴绉嶏紝浣嗕粎鏀寔鈥滃崟宸モ濈殑HTTP閫氳銆傛湁瑙佸強姝わ紝HTML5鏂拌鑼冧腑鎺ㄥ嚭浜嗗熀浜庢祻瑙堝櫒鐨刉ebSocket锛屽紑鍙戜簡搴曞眰鐨勬帴鍙o紝鍏佽鐢ㄦ埛鑳借繘琛屾洿寮哄ぇ鐨勬搷浣滐紝瓒呰秺浠ュ線鐨刋HR銆傜敤鎴锋棤椤荤涓夋柟妗嗘灦灏
绛旓細鍦ㄥ緢澶氶渶姹備笟鍔′腑锛岄兘闇瑕佹祻瑙堝櫒鍜屾湇鍔″櫒瀹炴椂閫氫俊鏉ュ疄鐜板姛鑳斤紝姣斿锛氭壂鐮佺櫥褰(鎵爜鍚庯紝鎵嬫満纭鐧诲綍锛孭C缃戦〉瀹屾垚鐧诲綍骞惰烦杞)銆佽鍗曡瑷鎻愰啋绛夛紝杩欎簺閮芥槸寤虹珛鍦ㄤ袱绔疄鏃堕氫俊鐨勫熀纭涓婄殑銆傚鍓嶇鑰岃█锛屾潵瀹炵幇娴忚鍣ㄥ拰鏈嶅姟鍣ㄥ疄鏃堕氫俊锛屾渶濂界殑閫夋嫨灏辨槸Socket.IO搴擄紝鑳藉蹇熺殑瀹炵幇涓ょ瀹炴椂閫氫俊鍔熻兘銆1銆佷粈涔堟槸 ...
绛旓細鏄笉鏄枃浠舵祦 socket 娌℃湁姝e父鍏抽棴涔嬬被鐨剘~鐒跺悗瀵艰嚧姝婚攣锛侊紒
绛旓細socket.io鏄竴涓猈ebSocket鍗忚鐨勫疄鐜帮紝鐢ㄥ畠浣犲彲浠ヨ繘琛寃ebsocket閫氫俊锛岃繖鏄簲鐢ㄥ眰 node.js net.socket鏄郴缁焥ocket鎺ュ彛锛岀敤瀹冧綘鍙互鎿嶄綔linux socket锛岃繖鏄紶杈撳眰 websocket鍗忚鏈川涓婁篃鏄娇鐢ㄧ郴缁焥ocket锛屽畠鏄妸socket寮曞叆浜唄ttp閫氫俊锛屼篃灏辨槸涓嶄娇鐢80绔彛杩涜http閫氫俊銆傚畠鐨勭洰鐨勬槸寤虹珛鍏ㄥ弻宸ョ殑杩炴帴锛屽彲浠ョ敤鏉...
绛旓細涓涓熀浜 Node.js 鐨勫疄鏃跺簲鐢ㄧ▼搴忔鏋讹紝鍦ㄥ嵆鏃堕氳銆侀氱煡涓庢秷鎭帹閫侊紝瀹炴椂鍒嗘瀽绛夊満鏅腑鏈夎緝涓哄箍娉涚殑搴旂敤 涓嶇煡閬撴庝箞鎼缓egg椤圭洰鐨勭炕涓嬩互鍓嶇殑鏂囩珷 鍒拌繖閲宔gg-socket.io宸茬粡寮鍚苟閰嶇疆瀹屾瘯浜, 鎺ヤ笅鏉ユ垜浠氨瑕佺紪鍐欒矾鐢卞拰鎺у埗鍣ㄤ簡 鍒拌繖閲屾湇鍔$瀹屾垚, 涓嬮潰鎴戜滑鏉ュ啓涓涓畝鍗鐨剆ocket.io瀹㈡埛绔 鍒拌繖灏辩粨鏉熶簡,...
绛旓細鎮ㄩ棶鐨勬槸nodesocketio鍗燾pu杩囧ぇ鎬庝箞鍥炰簨鍚楋紵闀胯疆璇佸ぇ閲忚繛鎺ュ拰骞挎挱绛夈1銆侀暱杞锛氶粯璁や娇鐢ㄩ暱杞鏉ュ疄鐜板疄鏃堕氫俊锛屽湪闀挎椂闂存病鏈夋柊娑堟伅鐨勬儏鍐典笅锛屼細鎸佺画鍙戦佽姹傦紝浠庤屽鑷碈PU璧勬簮琚秷鑰椼2銆佸ぇ閲忚繛鎺ュ拰骞挎挱锛氬簲鐢ㄧ▼搴忓鐞嗗ぇ閲忕殑骞跺彂杩炴帴鎴栭绻佸湴杩涜骞挎挱鎿嶄綔锛屼細澧炲姞鏈嶅姟鍣ㄧ殑璐熻浇锛屽鑷碈PU鍗犵敤杩囬珮銆3銆佷笉...
绛旓細鍙互鏄暱杩炴帴銆傚叧浜socket.io锛氭祻瑙堝櫒铏界劧涔熷睘浜庡鎴风鐨勪竴绉嶏紝浣嗕粎鏀寔鈥滃崟宸モ濈殑 HTTP 閫氳銆傛湁瑙佸強姝わ紝HTML5 鏂拌鑼冧腑鎺ㄥ嚭浜嗗熀浜庢祻瑙堝櫒鐨 WebSocket锛屽紑鍙戜簡搴曞眰鐨勬帴鍙o紝鍏佽鐢ㄦ埛鑳借繘琛 鏇村己澶х殑鎿嶄綔锛岃秴瓒婁互寰鐨 XHR銆傜敤鎴锋棤椤荤涓夋柟妗嗘灦灏卞彲浠ョ洿鎺ヤ笌 Node TCP 鏈嶅姟鍣 杩涜 Socket 閫氳銆備絾鍙堣...
绛旓細鍏跺疄鍗曠函鐨勯潬socket.io鍘昏闂法鍩熸槸鍙鐨勶紝鍑洪棶棰樼殑鏄痵ession锛屼篃灏辨槸cookie浣爏ocket.io鏈嶅姟绔痠o.set('authorization鈥,function(handshakeData,callback){/***}鑲畾鏈夎繖涓璇侊紝涓鏃﹁法鍩燂紝handshakeData.headers.cookie鏄幏鍙栫殑鏈嶅姟鍣ㄥ煙鐨刢ookie.鑰宔xpress鐨剆ession绠$悊涔熸槸灏哻ookie璁板綍鍦ㄦ湇鍔$閲岀殑锛屽彧鏈変綘...
绛旓細鏂规硶濡備笅锛 1銆佹寜WIN+Q缁勫悎閿墦寮鎼滅储妗嗭紝杈撳叆"杩滅▼妗岄潰杩炴帴"锛岀偣鍑讳笅鏂规彁绀虹殑杩滅▼妗岄潰杩炴帴 2銆佸湪鎵撳紑鐨勮繛鎺ョ獥鍙o紝杈撳叆杩滅▼鏈哄櫒鐨勮绠楁満鍚嶆垨IP鍦板潃锛屽拰绔彛 3銆佺郴缁熷彲鑳戒細鏈変竴浜涙彁绀猴紝鐐瑰嚮纭銆
绛旓細netty-socekt.IO瀹樼綉 socket.io鏄竴涓猲etty.socket node鐗堢殑java瀹炵幇鐗堬紝鍏舵ц兘浼樹簬webSocket绛塻ocket鎶鏈紝socket.io鏈塶ameSpace绛夛紝鍒嗗尯鏂瑰紡锛屾瘮杈冪伒娲汇俹riginHost涓簊ocket瀹㈡埛绔殑鍦板潃锛宻erverHost璇蜂娇鐢╥p锛宭z鍦ㄤ娇鐢ㄨ繃绋嬩腑灏濊瘯杩囦娇鐢╨ocalhost锛屼絾鏈嶅姟鏈兘璋冪敤鎴愬姛銆socketIoConfig鐢ㄤ簬鐢熶骇bean锛屽湪socket...