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 count connections/clients #1070

jjhesk opened this Issue Aug 21, 2018 · 2 comments


None yet
2 participants

jjhesk commented Aug 21, 2018

in websocket, are there such method to call for how many clients that are subscribed? are there such demo code for references?


This comment has been minimized.


kataras commented Aug 21, 2018

Yes, GetTotalConnections() will return the number of connected clients.

The GetConnectionsByRoom(roomName string) []Connection will give you the connections connected to a specific room. However, you can manually track however you want the connected client; you can just make a counter or "a" feature inside the OnConnection or your websocket handler's body.

@kataras kataras added the question label Aug 21, 2018

@kataras kataras changed the title from websocket to websocket count connections/clients Aug 21, 2018


This comment has been minimized.

jjhesk commented Aug 23, 2018

according to

"a" feature inside the OnConnection or your websocket handler's body.

i found that there is the emit message function in the handleConnection. how do I pass in thews *websocket.Server into this callback function? do u suggesting to use chan *websocket.Server to get back the number digit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment