我的代码是:
var arrClients = {};
var client = {
socket:null,
username:null,
uid:false,
time:null
};
io.sockets.on('connection', function (socket) {
socket.on('message', function (msg) {
var sendParmas = {};
if(isFirstTime){
client.socket = socket;
client.username = msg;
client.uid = uuid.v4();
client.time = getTime();
arrClients["'" + client.uid + "'"] = client;
sendParmas.text=arrClients;
sendParmas.type='firstTime';
socket.emit('system',sendParmas);
socket.broadcast.emit('system',sendParmas);
}
});
});
client.socket = null;可以运行,如果没有提示:[RangeError:超出最大调用堆栈大小]