在我的应用程序socket中传递为thisusingbind和call
socket.on( 'handle', someFunc.bind(socket) );
function someFunc() {
var socket = this;
...
anotherFunc.call( socket, 'abc', ... );
}
我希望确保这this确实是一个socket- 忘记 - 使用func(...)而不是func.call(socket,...).
function someFunc() {
var socket = this;
assert.ok( /* ensure this is instanceof a socket */ );
...
}
我如何做出断言?
socket里面有没有io = require('socket.io')我可以用的?