Closed mofan20 closed 2 years ago
const targetSockets = await Socket.find({ user: toUser?._id }); const targetSocketIdList = targetSockets?.map((socket) => socket.id) || []; if (targetSocketIdList.length) { ctx.socket.emit(targetSocketIdList, 'message', messageData); }
请教这里为啥能用数组? ctx.socket.emit(targetSocketIdList, 'message', messageData);
看懂了。。。tx
是支持的, 可以看下官方文档
const targetSockets = await Socket.find({ user: toUser?._id }); const targetSocketIdList = targetSockets?.map((socket) => socket.id) || []; if (targetSocketIdList.length) { ctx.socket.emit(targetSocketIdList, 'message', messageData); }
请教这里为啥能用数组? ctx.socket.emit(targetSocketIdList, 'message', messageData);