It seems like Game Center is sending same data twice

Is it possible for Game Center to send the exact same data to the same player twice?


I am frequently (not all of the time) noticing, the same exact data being received twice, which is causing issues in my application.


I am using the following functions in GameKitHelper to send and receive data in my application:


func sendDataToPlayer(data: Data!, gkPlayer: GKPlayer) 
{
   var playerArray: [GKPlayer] = [ ]
   playerArray.append(gkPlayer)
   do {
         try myMatch?.send(data, to: playerArray, dataMode: .reliable)
   }
   catch {
   }
}


    func match(_ match: GKMatch,
               didReceive data: Data,
               forRecipient recipient: GKPlayer,
              fromRemotePlayer player: GKPlayer)


I am experiencing the same exact data coming into the "didReceive data:" function with the exact same data, recipient and player values


Has anyone seen this duplicate data issue before?


I see this issue when testing with 2 real iPhones and the simulator (ie: 3 players). I do not see this issue when testing with 1 iPhone and the simualtor (ie: 2 players).



As a side question .... what is the difference between:


1) match(_: didReceive: forRecipient: fromRemotePlayer:)

and

2) match (_: didReceive: fromRemotePlayer:)

Accepted Reply

To work around this unexpected issue, I store the last few received messages and then compare any new messages I received against the ones stored. if there is a match, I simply throw the new incoming message away.

Replies

To work around this unexpected issue, I store the last few received messages and then compare any new messages I received against the ones stored. if there is a match, I simply throw the new incoming message away.