rocket chat user status change :statusConnection
Rocket.Chat Version: 0.55.0-develop Running Instances: DB Replicaset OpLog: Node Version:4.7.3 - x64
- when i close the browser, the stateConnection of the user will be assigned with offline automatically, i want to know rocket.chat did this in which source code file,and i want to add some other functions there.
the record in mongodb is below:
{ "_id" : "YeLmLWuEtAi9z2ZJQ", "createdAt" : ISODate("2017-06-04T06:45:43.482Z"), "services" : { "password" : { "bcrypt" : "$2a$10$.aAugS3TByW7kFUju2pRneC44Zil6sYeQoj6TLOHx/r3BcsOzxHYK", "reset" : { "token" : "41I5jTDzUFGEsAFLgUQV-WWG0o0N7iAPGZyamZuvwNL", "email" : "[email protected]", "when" : ISODate("2017-06-04T06:57:10.646Z"), "reason" : "reset" } }, "email" : { "verificationTokens" : [ { "token" : "roz-SIZsZfWEAjbjQoIf_r8Iy3sKdG2DH9ykdIQPDx8", "address" : "[email protected]", "when" : ISODate("2017-06-04T06:45:43.506Z") } ] }, "resume" : { "loginTokens" : [ { "when" : ISODate("2017-06-05T03:13:15.306Z"), "hashedToken" : "fLiIydpbjZAKPioKyOaAevZlshOCkSAKMgx0pR69mAo=" } ] } }, "emails" : [ { "address" : "[email protected]", "verified" : true } ], "type" : "user", "status" : "offline", "active" : true, "name" : "kai", "_updatedAt" : ISODate("2017-06-05T03:13:21.861Z"), "roles" : [ "user", "admin" ], "verified" : false, "lastLogin" : ISODate("2017-06-05T03:13:15.303Z"), "statusConnection" : "offline", "utcOffset" : 8, "username" : "XXDS", "statusDefault" : "busy" }
the connection status is handled by konecty:user-presence package..
this is the code called when user lost its connection to the server.
the package konecty:user-presence is not in the rocket.chat project of verison 0.55.0-develop. so if i want to do something like saving some conditions of the user to mongodb when the statusConnection is changed to offline, how can i do? for example, i want to calculate the user's online time . when the user close all the tabs or the user logout himeself, the statusConnection of the user will be offline, but i am not sure how can i do
you can set a callback to be run whenever a user's status changes (like this one)