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

iOS Data Stream example #3134

Open
jasperaelvoet opened this issue Dec 21, 2024 · 0 comments
Open

iOS Data Stream example #3134

jasperaelvoet opened this issue Dec 21, 2024 · 0 comments
Labels
needs-triage Issue still needs to be assigned, labeled and deduplicated type: question General questions (we may not have time to provide an answer)

Comments

@jasperaelvoet
Copy link

Hi, I am trying to create two data streams between two iOS devices. However, I have unable to get it to work, and there seems to be no clear example in the documentation.

Here is how I create the Stream objects (this runs when a connection has been successfully established):

var inputStream: InputStream?
var outputStream: OutputStream?

Stream
  .getBoundStreams(
    withBufferSize: 1024,
    inputStream: &inputStream,
    outputStream: &outputStream)

guard let inputStream = inputStream, let outputStream = outputStream
else
{
  print("Failed to create input/output streams")
  return
}

nearbyConnectionManager
  .startStream(
    inputStream,
    to: [endpointID])

self.connectedPeers[connectedIndex].audioStream = outputStream
self.connectedPeers[connectedIndex].audioStream!.schedule(in: .main, forMode: .default)
self.connectedPeers[connectedIndex].audioStream!.open()

And then the receiving of the streams:

public func connectionManager(
  _ connectionManager: ConnectionManager, didReceive stream: InputStream,
  withID payloadID: PayloadID, from endpointID: EndpointID,
  cancellationToken token: CancellationToken)
{
  print("Received stream from \(endpointID)")

  stream.open()
  stream.delegate = self
  stream.schedule(in: .current, forMode: .default)
}

For testing purposes, I send 10 bytes 4x per second.

On the receiving end, I get this error:

Received stream from ZCUF
TRANSFER UPDATE: progress(<NSProgress: 0x303c06400> : Parent: 0x0 (portion: 0) / Fraction completed: 0.0000 / Completed: 10 of -1  )
E0000 00:00:1734809808.195350 3542100 payload_manager.cc:1424] ProcessDataPacket: [data: error] endpoint_id=ZCUF; payload_id=3260928757190108707
I0000 00:00:1734809808.195654 3542213 client_proxy.cc:1061] ClientProxy [reporting onPayloadProgress]: client=11369573624546782; endpoint_id=ZCUF; payload_id=3260928757190108707, payload_status=Failure
TRANSFER UPDATE: failure

I tried modifying feature flags to see if that would resolve the issue, but was unsuccessful.

Would be great if someone could share a working example!

Thanks in advance

@jasperaelvoet jasperaelvoet added needs-triage Issue still needs to be assigned, labeled and deduplicated type: question General questions (we may not have time to provide an answer) labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Issue still needs to be assigned, labeled and deduplicated type: question General questions (we may not have time to provide an answer)
Projects
None yet
Development

No branches or pull requests

1 participant