【发布时间】:2021-09-23 08:51:07
【问题描述】:
我正在使用 vue.js(Laravel) 连接我的聊天节点服务器,它的连接套接字但发出的功能不起作用。
var socket = io.connect('http://localhost:3000/api/message');
socket.on('connect', function () {
var mapdata = {chatId: this.chatIdd, userId: this.userIdd}
socket.emit("joinChat", JSON.stringify(mapdata) ,function(confirmation){
alert('Work');
console.log(confirmation);
});
}.bind(this));
socket.on('msgReceive', function () {
}.bind(this));
alert('Work') 未显示。我该如何解决这个问题?
这是服务端函数
socket.on("joinChat", async msg => {
let objectValue = await JSON.parse(msg);
chatId = objectValue["chatId"];
socket.join(chatId);
});
【问题讨论】:
-
我用服务器端代码更新问题
标签: node.js vue.js websocket socket.io