-
Notifications
You must be signed in to change notification settings - Fork 181
Description
Project
Nearby Connections
Language
C++
OS Platform
Other
What happened?
[RUNNING THIS ON ANDROID]
I'm using the compiled SDK to create an Expo module to use in our future app.
So actually I'm not really aware of what happens under the hood in this codebase and I apologize in advance if this is not the right place where to post this.
I'm able to let everything working as expected (advertising, discovering, connections, etc..).
However, when trying to send a Stream payload, even if it is correctly sent (I can see a log printed in the sendPayload Task onSuccess listener), it is not received from the target endpoint.
Investigating the issue, I found out the stream payload was not sent because the associated stream had no data yet to read.
How I was generating the payload:
val pipedOutputStream = PipedOutputStream()
val pipedInputStream = PipedInputStream(pipedOutputStream, data.size)
val payload = Payload.fromStream(pipedInputStream)
and then just sending it out with: connectionsClient.sendPayload(endpointIdsStrings, payload)
it was correctly sent but not received.
As soon as I write even a single byte to the outputStream before sending the Payload, it is then correctly received on the other hand and I can continue writing my data.
As I see, e.g., Piped streams can be created and connected and just wait for new data. I don't understand why a stream payload can't be sent and waiting for it.
Thanks!
What did you expect to happen?
I would expect that I can send a Stream Payload even if no data has been written yet.
How can we reproduce it (as minimally and precisely as possible)?
- Having 2 devices already connected (any strategy is ok)
- Create a PipedInputStream and a PipedOutputStream, connect them together
- Generate a Stream payload with the previously created input stream
- send the stream payload to the other device
- the other device will never receive it
How often does this bug happen?
Every time
Standalone code to reproduce the issue
import com.google.android.gms.nearby.Nearby
import com.google.android.gms.nearby.connection.Payload
import java.io.PipedInputStream
import java.io.PipedOutputStream
val _connectionsClient = Nearby.getConnectionsClient(_safeCurrentActivity)
val pipedOutputStream = PipedOutputStream()
val pipedInputStream = PipedInputStream(pipedOutputStream, 1024)
val payload = Payload.fromStream(pipedInputStream)
_connectionsClient.sendPayload(<id of the target device>, payload)
Relevant log output
Anything else we need to know?
No response