我有这样的事情:
io.sockets.on('connection', function(player) {
var currentRoom;
currentRoom='lobby';
player.join(currentRoom);
player.broadcast.to(currentRoom).emit('newPlayer');
require('./test').test(player);
player.on('changeroom',function(room) {
player.leave(currentRoom);
player.join(room);
currentRoom = room;
});
});
测试.js:
exports.test = function(player) {
player.on('message',function(msg) {
player.broadcast.to('lobby').emit('message',msg);
});
}
我想在 test.js 中将“大厅”更改为 currentRoom 值。我怎样才能做到这一点?