[quote='796608022, DTS Engineer, /thread/759890?answerId=796608022#796608022']
Finally, how is MCPeerID coming into this? I thought you were using GameKit?
[/quote]
Actually, I am using both GameKit and MCSession.
Trying to play with fragmenting the data, as you prompted. Although it is more or less clear how to send data:
func sendData(dictionaryWithData dictionary: Dictionary<String, Any>, toPeer targetPeers: [MCPeerID]) {
do {
let dataToSend = try NSKeyedArchiver.archivedData(withRootObject: dictionary, requiringSecureCoding: true)
let fragments = fragmentsForMessage(dataToSend, messageID: 0xa1a2a3a4, maxMessageBytesInFragment: 50000)
for fragment in fragments {
try session.send(fragment, toPeers: targetPeers, with: MCSessionSendDataMode.reliable)
}
}
catch {
}
}
... I am frankly a bit stuck as to how to handle it in
func session(_ session: MCSession,didReceive data: Data,fromPeer peerID: MCPeerID)
{
DispatchQueue.main.async {
do {
....
Append data to a property and then at some point implement NSDictionary.unsecureUnarchived? How to know when to implement?
When reading the data, I am also getting errors
Error:Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0xffffffa1, 0xffffffa2, 0xffffffa3, 0xffffffa4, 0x0, 0x0, 0x0, 0x6)" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0xffffffa1, 0xffffffa2, 0xffffffa3, 0xffffffa4, 0x0, 0x0, 0x0, 0x6)}
Topic:
App & System Services
SubTopic:
Networking
Tags: