Open sarbogast opened 9 months ago
This may be happening due to the async nature of the flutter method channel.
In my local experiments I am getting response from sendBytes before transfer update.
D/nearby_connections(27109): sentPayload: -8806054461585292721
I/flutter (27109): sendBytesPayload in flutter
D/nearby_connections(27109): onPayloadTransferUpdate :-8806054461585292721
I/flutter (27109): 2
D/nearby_connections(27109): onPayloadTransferUpdate :-8806054461585292721
The only other option I feel would be to use some sort of synchronization mechanism on Java side
so that sendBytesPayload
only returns after a successful call to payloadTransferUpdate.
Another option could be to separate out the Payload preparation and Payload sending methods.
Upon preparing the payload, you should get the payload Id back, after which you may send the payload in another call.
Sometimes, when I send a bytes payload, it fails to transmit, and I receive an error in
onPayloadTransferUpdate
. Then, I would like to try resending the same payload again, but for that I would need to be able to correlate the payload ID I get inPayloadTransferUpdate
with the ID of the payload that was sent, but I only get a payload ID back when sending a file, not bytes. I tried to add this feature myself, makingsendBytesPayload
return aFuture<int>
instead of aFuture<void>
, but it seems to be useless because the transfer update is called before sendBytes returns.Would it even be possible?