Reputation: 3
I am using Google Nearby Connections API in a React Native application to transfer data between two Android devices.
This data needs to be erased from the "sender device" after the confirmation from the "receiver device", and then permanently saved to the device that received it.
I'm using the onPayloadTransferUpdate(SUCCESS) method on both devices as confirmation of data delivery.
Does the implementation of the API ensure that this method will run simultaneously on both devices in order to prevent data from coexisting after the transfer or that it will not be lost? Or is it necessary to implement in the application the logic to guarantee the commit of this transaction? I was thinking in something like two-phase commit.
Upvotes: 0
Views: 131
Reputation: 2033
It's safer to do the two-phase commit. When the sender receives onPayloadTransferUpdate(SUCCESS), it only means that the bits have left the device. It's only after the receiver receives onPayloadTransferUpdate(SUCCESS) that the transfer is complete.
Upvotes: 1