[temp] throttle socket io connection (#3260)
This commit is contained in:
parent
e51d31c452
commit
3da8267449
1 changed files with 9 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ var redis = require("redis");
|
|||
var request = require('superagent');
|
||||
|
||||
var conf = get_conf();
|
||||
var flags = {};
|
||||
var subscriber = redis.createClient(conf.redis_socketio || conf.redis_async_broker_port);
|
||||
|
||||
// serve socketio
|
||||
|
|
@ -31,6 +32,14 @@ io.on('connection', function(socket){
|
|||
return;
|
||||
}
|
||||
|
||||
if(flags[sid]) {
|
||||
// throttle this function
|
||||
return;
|
||||
}
|
||||
|
||||
flags[sid] = sid;
|
||||
setTimeout(function() { flags[sid] = null; }, 10000);
|
||||
|
||||
socket.user = cookie.parse(socket.request.headers.cookie).user_id;
|
||||
|
||||
// console.log("firing get_user_info");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue