alexkendall / react-native-bluetooth-cross-platform

Cross-Platform Bluetooth & WiFi React Native Module. Powered by underdark http://underdark.io/.
179 stars 35 forks source link

Emit user redetected upon reconnection #55

Closed azanli closed 5 years ago

azanli commented 5 years ago

The problem Upon reconnecting to the network, the "userDetected" event does not fire due to returning null in checkForNewUser(user). This is unfortunate because there may be a number of reasons why the user disconnected (switched screens, etc) and may wish to reconnect to nearby users, usually by letting them know they've been "detected" or in this case, "redetected".

The solution Emit a "redetectedUser" event that's similar to "detectedUser" but under the condition that the user already exists in the nearbyUsers list.

The reason This helps to bridge a disconnected user back into whatever ongoing processes and can facilitate in syncing whatever state there is back up with the reconnected user.

azanli commented 5 years ago

Nevermind. This actually introduced a bug in emitting too many "peerRedetected" messages across the JS bridge. Will resubmit if I find a way around it, otherwise, I have another potential solution - if anyone's interested, just PM me.