Stay organized with collections
Save and categorize content based on your preferences.
Once connections are established between devices, you can start exchanging data.
The exchanged data can take the form of a simple byte array, such as a short
text message; a file, such as a photo or video; or a stream, such as the audio
stream from the device’s microphone.
Data can be sent using the following connection manager instance methods:
send(_:to:)
startStream(_:to:)
sendResource(at:withName:to:)
The following connection manager delegate methods can be utilized when receiving
data.
Swift
extensionExample:ConnectionManagerDelegate{funcconnectionManager(_connectionManager:ConnectionManager,didReceivedata:Data,withIDpayloadID:PayloadID,fromendpointID:EndpointID){// A simple byte payload has been received. This will always include the full data.}funcconnectionManager(_connectionManager:ConnectionManager,didReceivestream:InputStream,withIDpayloadID:PayloadID,fromendpointID:EndpointID,cancellationTokentoken:CancellationToken){// We have received a readable stream.}funcconnectionManager(_connectionManager:ConnectionManager,didStartReceivingResourceWithIDpayloadID:PayloadID,fromendpointID:EndpointID,atlocalURL:URL,withNamename:String,cancellationTokentoken:CancellationToken){// We have started receiving a file. We will receive a separate transfer update// event when complete.}funcconnectionManager(_connectionManager:ConnectionManager,didReceiveTransferUpdateupdate:TransferUpdate,fromendpointID:EndpointID,forPayloadpayloadID:PayloadID){// A success, failure, cancelation or progress update.}}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-04-23 UTC."],[[["After establishing connections between devices, data exchange can commence, encompassing various formats like byte arrays, files, or streams."],["`ConnectionManager` offers methods such as `send(_:to:)`, `startStream(_:to:)`, and `sendResource(at:withName:to:)` for initiating data transmission."],["To receive data, implement the `ConnectionManagerDelegate` protocol, providing methods to handle byte payloads, streams, file transfers, and transfer updates."],["While payloads of the same type maintain their sending order upon arrival, there's no guarantee of order preservation across different payload types."]]],[]]