Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教:ctx.socket.emit的第一个参数只能是字符串,为啥代码能用数组? #470

Closed
mofan20 opened this issue Jan 28, 2022 · 2 comments

Comments

@mofan20
Copy link

mofan20 commented Jan 28, 2022

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);

@mofan20
Copy link
Author

mofan20 commented Jan 28, 2022

看懂了。。。tx

@mofan20 mofan20 closed this as completed Jan 28, 2022
@yinxin630
Copy link
Owner

是支持的, 可以看下官方文档

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants