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类中添加一个可以存储信息的Tag字段 #160

Closed
zwllh123 opened this issue Mar 14, 2025 · 1 comment
Closed

WebSocket类中添加一个可以存储信息的Tag字段 #160

zwllh123 opened this issue Mar 14, 2025 · 1 comment

Comments

@zwllh123
Copy link
Member

用于存储一些会话Id信息,比如在初始化的时候,提交了一个token,可以跟这个socket关联,后边的msg就不用带这个token都知道是这个socket上报的信息,添加一个这个字段可以减少很多业务逻辑的编写

@nnhy
Copy link
Member

nnhy commented Mar 27, 2025

可以保存在HttpContext.Items里面,也可以在缓存里面保存两份,例如:
cache.set("node:ws", websocket);
cache.set("node:token", token);

@nnhy nnhy closed this as completed Mar 27, 2025
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