Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
358 views
in Technique[技术] by (71.8m points)

javascript - 发射在铬上工作正常,但在Firefox上不工作(an emit works fine on chrome but doesn't work on firefox)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...