can someone explain why is that ,
(有人可以解释为什么吗,)
the console log on the client side before the emit shows which mean the emit should be executed but nothing happens on the server .
(发射之前的客户端控制台日志显示,这意味着发射应该被执行,但是服务器上没有任何反应。)
server side :
(服务器端 :)
socket.on('newGame', () => {
let roomID = playersController.getPlayerRoomID(socket.id)
socket.broadcast.to(roomID).emit('newGame?', 'do u want to start a new game?')
socket.on('confirmNewGame', () => {
console.log('confirmed')
io.to(roomID).emit('initialNewGame')
})
})
client side :
(客户端 :)
socket.on('newGame?', (data) => {
if (confirm(data)) {
console.log('confirmed')
// tested on chrome , doesn't emit on firefox don't know why
socket.emit('confirmNewGame')
}
})
socket.on('initialNewGame', () => {
initialNewGame()
})
ask by src255x translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…