0

我正在使用 socket.io,我需要在用户连接到套接字的同时发送电子邮件地址。

我想做这样的事情:(使用vue)

//On the client side
data () {
    return{
        userEmail: 'test@gmail.com'
        socket: io('localhost:5000/messages', {userEmail: this.userEmail})
    }
}

//On the server
io.on('connection', function(socket, data){
    socket.email = data.userEmail
})
4

0 回答 0