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

UserPresence.activeLogs and callback method are not matching #49

Open
vodkhang opened this issue Aug 4, 2019 · 1 comment
Open

UserPresence.activeLogs and callback method are not matching #49

vodkhang opened this issue Aug 4, 2019 · 1 comment

Comments

@vodkhang
Copy link

vodkhang commented Aug 4, 2019

Hi all,

I am using Rocket.chat for my project and need to keep track if visitor is online, away or offline.

My Code:

Meteor.startup(() => {
	UserPresenceEvents.on('setStatus', (session, status, metadata) => {
		console.log('setStatus - status:  ', status);
		console.log('setStatus - session: ', session);
		console.log('setStatus - metadata: ', metadata);
		const logs = UserPresence.activeLogs();
		console.log('UserPresence - log: ', logs);

		if (metadata && metadata.visitor) {
			RocketChat.models.LivechatInquiry.updateVisitorStatus(metadata.visitor, status);
			RocketChat.models.Rooms.updateVisitorStatus(metadata.visitor, status);
		}
	});
});

I leave the client for 60 seconds so a message away is sent from client to server. The server part of UserPresence captures that correctly, but somehow my callback method receives a different value

Server's log:

I20190804-16:18:33.801(10)? [user-presence] setConnection tb5TEakSDWMqPWPG5 fKcSmu6Xs3zxucra5 away
I20190804-16:18:33.831(10)? setStatus - status:   online
I20190804-16:18:33.831(10)? setStatus - session:  tb5TEakSDWMqPWPG5
I20190804-16:18:33.832(10)? setStatus - metadata:  { visitor: 'tb5TEakSDWMqPWPG5' }

When I turned off the tab, the server receives a remove connection message, but my method callback still receives an online status. I am doing this correctly, or any setting needs to be turned on?

I20190804-16:30:48.574(10)? [user-presence] removeConnection fKcSmu6Xs3zxucra5
I20190804-16:30:48.586(10)? setStatus - status:   online
I20190804-16:30:48.586(10)? setStatus - session:  2DBBuWjyvEbf2maLN
I20190804-16:30:48.587(10)? setStatus - metadata:  undefined
@vodkhang
Copy link
Author

vodkhang commented Aug 8, 2019

Anyone has any idea here?

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

1 participant