This is the correct way of doing this:
Server.on('request', function(request) {
const WSCon = request.accept(null, request.origin);
let player = "none";
function HandleRoomEnter(player) {
player = "Conan";
console.log("setting: "+player);
}
function HandleReadyness(player) {
console.log("getting: "+player);
}
WSCon.on('message', function(message) {
if (data.action == 0) HandleRoomEnter(player);
if (data.action == 1) HandleReadyness(player);
});
});
Also please use let or const instead of var.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…