Hello,I am developing an iOS game that will use the Network.framework to communicate between 2-6 iOS devices (hopefully more depending on performance).I began with studying the Apple Tic-Tac-Toe sample project. Like that project, I started with TCP. One device is the server (the source of truth) and the other devices are clients. The server increments a step, and the clients acknowledge the step. I'm trying to achieve a step rate of about 30 - 100ms I want to compare performance with UDP. (I am fairly new to networking, though I use URLSession regularly.)In the WWDC 2019 session Advances in Networking, Part 2 at time 31:30 Tommy Pauly talks about Framing Protocols and shows a slide that reads "Use framing protocols to write common code across TCP and UDP transports."I have not seen an example anywhere of this. Does that mean the GameProtocol class itself can be used with UDP?class GameProtocol: NWProtocolFramerImplementation {
// This class is from the Tic-Tac-Toe project
}I have UDP working in a branch of my code, but it is not using GameProtocol like my TCP branch is.My TCP send:let contentContext = NWConnection.ContentContext(identifier: "GameMessage", metadata: [NWProtocolFramer.Message(gameMessageType: .gameMessage)])
connection.send(content: jsonData, contentContext: contentContext, isComplete: true, completion: .idempotent)My UDP send:connection.send(content: jsonData, completion: .contentProcessed { error in
if let error = error {
DDLogError("**ERROR** UDPConnection send | \(error.localizedDescription)")
}
})So I am interested in knowing more about what was meant by "Use framing protocols to write common code across TCP and UDP transports."Thanks!
2
0
2.5k