Slide 40
Slide 40 text
Network.framework receive
connection.receiveMessage { data, messageContext, isComplete, error in
if let error = error {
print("Failed to receive message \(error)")
} else if let data = data, isComplete {
print(String(data: data, encoding: .utf8)!)
}
}
connection.receive(minimumIncompleteLength: 2,
maximumLength: 4096) { data, context, isComplete, error in
if let error = error {
print("error", error)
} else if let data = data {
print("received: ", String(data: data, encoding: .utf8)!)
}
if isComplete, context == nil, error == nil {
print("END")
}
}