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

websocket 区分消息来自哪个连接 #534

Open
XXOO9 opened this issue Apr 23, 2024 · 2 comments
Open

websocket 区分消息来自哪个连接 #534

XXOO9 opened this issue Apr 23, 2024 · 2 comments

Comments

@XXOO9
Copy link

XXOO9 commented Apr 23, 2024

大佬,我创建了一个websocket服务器,并且与两个websocket客户端连接了。 当服务器收到消息的时候,我需要怎么区分消息来自于哪个客户端呢? 目前我是采用记录 WebSocketChannelPtr的fd来区分的,不知道大佬还有啥更好的办法没?感谢大佬

@ithewei
Copy link
Owner

ithewei commented Apr 23, 2024

智能指针本身,fd、id、peeraddr、或者通过setContextPtr设置上下文,都可以区分

@xs-411
Copy link

xs-411 commented May 10, 2024

不能使用fd来关联连接,因为fd会被复用.

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

3 participants