Thanks a lot! NWProtocolWebSocket seems perfect for the transmission of data. From what I understood, I can:
Have the device create their unique ID (UUID?)
Make the device be a browser and listener (while emitting a Bluetooth signal) simultaneously.
If the device's browser detects a listener (who's BLE signal RSSI passes a certain threshold, meaning the device is right next to/on top of the first), they cancel their own listener and send their unique ID.
Conversely, if the device's listener is connected to by another device's browser, the first device cancels their browser, and once they have received the other end's unique ID, they send their own unique ID.
The device makes a sanity check using your clever method by making sure that this unique ID pair doesn't already exist (which would otherwise mean that this connection has already been made by their opposite browsers and listeners during steps 2-4). If this pair already does exist, the new connection is cancelled.
Once the sanity check is passed, a WebSocket connection is made, and the data is transferred wirelessly between the two phones.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: