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

Disconnections Management #100

Open
Leonidas00000 opened this issue Feb 1, 2024 · 4 comments
Open

Disconnections Management #100

Leonidas00000 opened this issue Feb 1, 2024 · 4 comments

Comments

@Leonidas00000
Copy link

I'm trying to implement a broker with this library and i wanted to know if there is a easy way to detect disconnected clients, i didn't found "onDisconnect()" event or anything like that, i want to know how can i detect a disconnected client and get its "id".

@hsaturn
Copy link
Owner

hsaturn commented Mar 6, 2024

Hello

You're right, this is on my todo list. I've never been disconnected so I did not implement this. Not planned but I keep this issue for when I have time.

@Aurentiaco35
Copy link

Aurentiaco35 commented May 30, 2024

Hello,

I also want to detect disconnected clients, I tried to add myself but I couldn't manage it. Is there any update about it?

@Leonidas00000
Copy link
Author

Leonidas00000 commented May 30, 2024

Hello,

even though there is no a disconnection management implemented, i have managed to do it. I don´t know if this helps you but, i detected a client disconnection using

"Clients_connected = broker.clientsCount();"

With this command i can controll the number of clients i have connected to my broker, if i compare this number taken in two diferent moments of my "loop()", i can check if there was a disconnection in my broker and eventually do something with a conditional function.

Controlling which client disconnected is a little bit more difficult because the library does not support "last will message", but as i only have 6 devices, y created a 6 position vector that reloads every few seconds detecting the id of the clients that are connected in that moment to the broker, in that way i can detect which client get disconnected.

I´m still working on this, hope it helps!

@Aurentiaco35
Copy link

That would help thank you so much.

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