Socket.IO 1.2.0 发布,包括重要的 bug 修复和一些 API 更新。
更新内容如下:
服务器 Fixed the npm main property in the chat example (GH#1766) [BrianGeppert] Some grammar fixes to the chat example strings (GH#1784) [matthewcanty] Fixed room autopruning (memory leak fix) (GH#2 GH#12) [hallucynogenyc & rase-] Added tests to check room autopruning (GH#1792) [rase-] Fixed the backwards compatibility option for the resource option when used through.set (GH#1690) [rase-] Replaced the server constructor without the new keyword in README with createServer to avoid confusion (GH#1626) [thanpolas] Fixed grammar issues in the README (GH#1788) [jamesanthonyferguson] The origins option now takes a function so allowed origins can dynamically change at run time (GH#1777) [akamensky] Fixed the Server#close example (GH#1773) [AjayMT] Fixed typo in README code example (GH#280) [reem] Added missing support for XSS filters on IE (GH#254) [pawelatomic] Allow upgrades if a socket is still in closing state (GH#285) [lpinca & 3rd-Eden] Updated the debug module in socket.io-adapter (GH#7) [keskival] Fixed jsonp tests for transport close deferring (GH#289) [rase-] Fixed the install issue of the indexOf module (GH#16) [rase-]
客户端 Fixed binary transport check if the content-type header contains a charset (GH#342) [bimusiek] When upgrading wait for it to finish before closing transport (GH#356) [nkzawa] Fixed close defer tests (GH#346) [rase-] Fixed “jsonp polling iframe removal error” on connection close (GH#349) [aaronk6] Fixed namespace tests after dependency upgrade in socket.io server [rauchg] Possibility to use a relative url without schema (GH#754) [toshipon] Fixed manual reconnection via connect function (now public API) (GH#732) [nkzawa] Updated repository url (GH#762) [haqii] Delaying transport closing until the drain event to send all packets left in the buffer (GH#351, GH#352) [nkzawa & rase-] Now supports PhantomJS (GH#34) [divdavem] Fixed an error in strict mode (GH#355) [nkzawa] Had priority XHR over XDR (GH#341) [yujiosaka] Enabled to stop reconnection attempts (GH#766) [nkzawa] Fixed reconnection after reconnecting manually (GH#767) [nkzawa] Fixed reconnection tests (GH#768) [rase-]
socket.io-redis 新 API 功能示例: 你可以指定一个函数来检测 origins,代替之前的 string representation (though the string representation still works as usual): 1 2 3 4 5 6 7 8 | var sockets = io({
origins: function (origin, fn) {
if (origin == 'http://foo.example' ) {
return fn( null , true );
}
return fn( null , false );
}
});
|
初始化客户端的时候,不需要协议也能运行相关 urls : 1 | var socket = io( '//localhost:3000' );
|
你可以手动管理重新连接: 1 2 3 4 5 6 7 8 9 10 11 12 | var socket = io({ forceNew: true });
socket.once( 'connect' , function () {
socket.disconnect();
});
socket.once( 'disconnect' , function () {
socket.once( 'connect' , function () {
console.log( 'Connected for the second time!' );
});
socket.connect();
});
|
跟往常一样,你可以通过 CDN 获取新客户端: 1 | < script src = "https://cdn.socket.io/socket.io-1.2.0.js" >script >
|
Socket.IO 实现了实时双向的基于事件的通讯机制。旨在让各种浏览器与移动设备上实现实时app功能,模糊化各种传输机制。 Socket.IO 是跨平台,多种连接方式自动切换,做即时通讯方面的开发很方便,而且能和expressjs提供的传统请求方式很好的结合,即可以 在同一个域名,同一个端口提供两种连接方式:request/response, websocket(flashsocket,ajax…). 
|