Network Framework with multiple clients

How can I use the Network framework to establish a "client-server" type relationship between a server iPad and, say, 3 client iPads?

I've downloaded the TicTacToe sample app,

https://developer.apple.com/documentation/network/building_a_custom_peer-to-peer_protocol

which demonstrates nicely a connection between a PeerListener and a PeerBrowser.

However, I then tried to make an array of PeerConnection objects rather than a single one, and send data to each one separately from the PeerListener. However, what appears to happen is that the 1st PeerBrowser connects successfully, but when the 2nd PeerBrowser connects, it replaces the 1st PeerBrowser, and both PeerConnection objects in the array point to the 2nd PeerBrowser, so when I send data via either PeerConnection, the data arrives at the 2nd PeerBrowser.

Is it possible to do this? If so, how can I establish multiple PeerConnections between 1 "server" iPad and multiple "client" iPads?

Answered by southbayjt in 770391022

UPDATE: The func refreshResults(results: Set<NWBrowser.Result>) callback is being called multiple times for the first client only, which is how the PeerConnections array is ending up with duplicate connections to the first client. However, the excellent thing is that the array of PeerConnection objects seems to be working as hoped.

Accepted Answer

UPDATE: The func refreshResults(results: Set<NWBrowser.Result>) callback is being called multiple times for the first client only, which is how the PeerConnections array is ending up with duplicate connections to the first client. However, the excellent thing is that the array of PeerConnection objects seems to be working as hoped.

However, the excellent thing is that the array of PeerConnection objects seems to be working as hoped.

So you’re all good, right?

Because the approach you’ve outlined is the one I’d use (-:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Network Framework with multiple clients
 
 
Q