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

Server onDisconnect event #26

Closed
toninho opened this issue Mar 29, 2017 · 4 comments
Closed

Server onDisconnect event #26

toninho opened this issue Mar 29, 2017 · 4 comments

Comments

@toninho
Copy link

toninho commented Mar 29, 2017

I'm trying create a presence system using react-native-firebase but it seems the onDisconnect callback is never called.

var userid = 33;
var amOnline = firebase.database().ref('.info/connected');
var userRef = firebase.database().ref('presence/' + userid );
amOnline.on('value', function(snapshot) {
if (snapshot.val()) {
userRef.onDisconnect().remove();
userRef.set(true);
}
});

it's not this available to be used or am I making some confusing?

@Ehesp
Copy link
Member

Ehesp commented Mar 29, 2017

Thanks for reporting. Will be looked at this weekend. It's probably related to #25 where the events and listeners are all mangled up.

@toninho
Copy link
Author

toninho commented Mar 29, 2017

It's working.
Sorry, I just realized now this operation takes some time to be processed by the server.

@toninho toninho closed this as completed Mar 29, 2017
@AndrewHenderson
Copy link

AndrewHenderson commented Mar 29, 2017

the events and listeners are all mangled up.

@Ehesp by mangled do you mean the approach to using the listeners? My code in particular, or on Firebase's end?

If there is an issue in the approach of my code sample in #25, please advise. I'm more than willing to change it.

I was following the RNF examples approach @Salakar shared with me: https://github.com/invertase/react-native-firebase-examples/blob/1d3fd13d2f552560fa5630bc12ad04785e301edf/src/examples/chat/Chat.js

@Salakar
Copy link
Contributor

Salakar commented Mar 29, 2017

@AndrewHenderson there's some logic in the RNFirebase db implementation that's causing the issue you're experiencing.

RNFirebase's initial implementation of database refs has some logic in to de-duplicate refs and their listeners at the same path and query modifiers, obviously this is incorrect, two refs to the same path should both still get the initial event as well as the subsequent events, but the de-dupe logic breaks this, the first listener to a path with get both, the 2nd listener and onwards will only get new events that come through and no initial events. This is what needs fixing our end.

Nothing to worry about your end 👍

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

4 participants