websocket 区分消息来自哪个连接
XXOO9 opened this issue · comments
XXOO9 commented
大佬,我创建了一个websocket服务器,并且与两个websocket客户端连接了。 当服务器收到消息的时候,我需要怎么区分消息来自于哪个客户端呢? 目前我是采用记录 WebSocketChannelPtr的fd来区分的,不知道大佬还有啥更好的办法没?感谢大佬
ithewei commented
智能指针本身,fd、id、peeraddr、或者通过setContextPtr设置上下文,都可以区分
secret commented
不能使用fd来关联连接,因为fd会被复用.