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

TCPServer如何获取已连接client列表 #74

Open
MartinFate opened this issue Nov 21, 2020 · 4 comments
Open

TCPServer如何获取已连接client列表 #74

MartinFate opened this issue Nov 21, 2020 · 4 comments

Comments

@MartinFate
Copy link

需要定时或者外部条件触发时给某一client发送数据,如何获取session列表

@IronsDu
Copy link
Owner

IronsDu commented Nov 22, 2020

抱歉,没有提供之前的方法来获取。
需要在链接建立的回调里自己维护这个列表。
类似这里:
https://github.com/IronsDu/brynet/blob/master/examples/BroadCastServer.cpp#L27

@MartinFate
Copy link
Author

好的,谢谢,很不错的C++网络库

@MartinFate
Copy link
Author

我看BroadCastServer.cpp中维护客户端连接列表Clients没用同步操作,不加锁的话是否有线程安全问题

@IronsDu
Copy link
Owner

IronsDu commented Nov 24, 2020

哦,我是使用mainLoop投递到主线程里执行的,所以逻辑上来说是单线程。
你若直接在消息回调(也就是IO线程)里做的话,就需要加锁了。

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