我正在用io套接字编写一个聊天应用程序,但是当我重新加入剩下的房间时,我陷入了一个问题,我发送的消息被重复了,发送了(n次),我在Google上搜索了很多,但是却一无所获,我第一次加入任何房间都可以,但是当我离开并再次加入时,会出现问题
这是客户端(reactjs)
error: ‘comphelper::FlagRestorationGuard’ has a field ‘comphelper::FlagRestorationGuard::<anonymous>’ whose type uses the anonymous namespace [-Werror=subobject-linkage]
class FlagRestorationGuard
^~~~~~~~~~~~~~~~~~~~
这是服务器(nodejs)
// Log Messages to the console
this.socket.on("send-msg", info => {
console.log(info.msg);
});
joinRoomOne = () => {
this.socket.emit("join-room", { roomName: "room1" });
};
logMsgToRoomOne = () => {
this.socket.emit("send-msg", {
msg: "Hello World From Room One",
roomName: "room1"
});
};
joinRoomTwo = () => {
this.socket.emit("join-room", { roomName: "room2" });
};
logMsgToRoomTwo = () => {
this.socket.emit("send-msg", {
msg: "Hello World From Room Two",
roomName: "room2"
});
};
leaveRooms = () => {
this.socket.emit("leave-rooms");
};