socket.io中有一种方法可以在断开连接的事件中创建超时,然后检查用户是否已重新连接?
这个想法是只有在超时后没有重新连接用户时才在数据库中发出数据/保存用户状态
编辑:跟随@Are Wojciechowski回答,我已经完成了多标签和F5泛滥处理程序
我在nodeJS面临一些新的事情: process.nextTick
在passport.js的一些策略代码示例中,我们可以看到
passport.use(new LocalStrategy(
function (username, password, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
findByUsername(username, function (err, user) {
// ...
bcrypt.compare(password, user.password, function (err, res) {
// ...
});
})
});
}
));
Run Code Online (Sandbox Code Playgroud)
但在官方文档中,它没有被使用.(http://passportjs.org/guide/username-password/)
我所理解的是process.nextTick应该用于推迟同步堆栈以阻止事件.但在这个战略代码中,没有事件.
这样做有什么好处?
我正在尝试这个查询
SELECT date_trunc('day', commit_at) AS day, count(*)
FROM commits
GROUP BY date_trunc('day', commit_at)
ORDER BY date_trunc('day', commit_at) ASC;
Run Code Online (Sandbox Code Playgroud)
它返回
day | count
---------------------+-------
2015-05-18 00:00:00 | 5
2015-05-19 00:00:00 | 2
2015-05-21 00:00:00 | 2
(3 lignes)
Run Code Online (Sandbox Code Playgroud)
问题是:我如何才能强制将空天数包含在结果中?
day | count
---------------------+-------
2015-05-18 00:00:00 | 5
2015-05-19 00:00:00 | 2
2015-05-20 00:00:00 | 0
2015-05-21 00:00:00 | 2
(3 lignes)
Run Code Online (Sandbox Code Playgroud) 写这样的东西时:
$(document).ready ->
doSomething()
doSomething = ->
alert('Nothing to do')
Run Code Online (Sandbox Code Playgroud)
编译成
$(document).ready(function() {
return doSomething();
});
doSomething = function() {
return alert('Nothing to do');
};
Run Code Online (Sandbox Code Playgroud)
据我所知,return语句用于值(字符串,数组,整数......)
为什么coffeescript会这样做?
javascript ×2
node.js ×2
coffeescript ×1
express ×1
passport.js ×1
postgresql ×1
sails.js ×1
select ×1
socket.io ×1
sql ×1