mochi-mqtt / server

The fully compliant, embeddable high-performance Go MQTT v5 server for IoT, smarthome, and pubsub
MIT License
1.29k stars 222 forks source link

Added client.StopTime(), to expose `disconnected` #400

Closed snej closed 6 months ago

snej commented 6 months ago

My persistence hook needs to know what time a client disconnected. The field Client.State.disconnected has that information but it's not exposed in the API, so I added a simple public accessor method Client.StopTime().

coveralls commented 6 months ago

Pull Request Test Coverage Report for Build 9038259883

Details


Totals Coverage Status
Change from base Build 8892157277: 0.001%
Covered Lines: 6160
Relevant Lines: 6246

💛 - Coveralls
werbenhu commented 6 months ago

@snej It would be better to add a test case to Client.StopTime().

snej commented 6 months ago

Added a check to TestClientStop(). I also noticed a race condition in that test (comparing a time against time.Now) and fixed it to allow a one-second discrepancy.