Sign In Register

How can we help you today?

Start a new topic

Receiving packages multiple times

I'm having some trouble when trying to disconnect from realtime matches.


I've made a lobby system where players can join rooms and when the rooms are full, the room creators can start the game.

Using Spark.getConfig().getMatchConfig(theMatchShortcode).createPendingMatch("",0 , tempPlayerList) , when starting a 1v1 match, it always starts 2 matches with both players set as participants.

I am only able to disconnect the players just from one of the 2 matches, because I can't seem to get the id of the second match.

When the players start a new match (from the lobby), all realtime packages sent are now duplicated.

It gets even worse when the process is repeated. Repeat the process 6 times, you get 12 matches (half of them with 0 participants because I managed to disconnect the players) and all packages get duplicated 6 times.


How can I properly disconnect and if it's not meant to start 2 matches, how can I prevent that from happening as I'm not running create pending match multiple times. 1 CreatePendingMatch => 2 Matches.



 Hey man, for me, it seems unusual that a pending match is created with an empty match group name...., I did create pending games with the same API and it seems fine. 


1 person likes this

Hey. Thanks for the info. I did change it by adding "multiplayer" as the match group. The documentation says that "Any existing pending matches for these players with the same matchGroup will be cancelled."  but it doesn't seem to work, although I can't really see what pending matches get created because my match instances start immediately. I still get 2 match instances and still get the same problems as before (the same packages being received multiple times, directly proportional to the number times the users exit and enter new matches). 


I'm guessing that the multiple packages are just a side-effect of multiple match instances being started. I don't really know how to prevent it from doing that.



dude, I am not sure what is the problem you came across, but the line of code you wrote earlier indicates you passed "" as the first argument which is the matchgroup name. Anyway,  I guess you might as well try to create pending game with custom query, and set a flag in the match data, then if a game is created and satisfy your condition, turn off the flag in the match data, then other pending matches would not meet the criteria, and then they would not be returned for auto combination.  Of cause, you need to update the match data in the match config custom code.


matchQuery = {"matchData.numberPlayers": {"$gte": players.length}};
        }
        // $eq     Matches values that are equal to a specified value.
        // $gt     Matches values that are greater than a specified value.
        // $gte     Matches values that are greater than or equal to a specified value.
        // $in     Matches any of the values specified in an array.
        // $lt     Matches values that are less than a specified value.
        // $lte     Matches values that are less than or equal to a specified value.
        // $ne     Matches all values that are not equal to a specified value.
        // $nin     Matches none of the values specified in an array.
      
        config.createPendingMatchWithCustomQuery(
            matchID,
            0,
            matchQuery,
           { "numberPlayers":2   }
            players
        );


From my experience, I only create pending match through the match config when I have my custom matching code, otherwise, I would simply send a match request other than managing the pending match myself.


not sure I am giving useful tips, hopefully, it rings you a bell.

Figured it out. 

The multiple packages issue was completely unrelated. Unity wasn't running the function that removed my receivePackage function from the gamesparks ReceivePackageDelegate ... The function was literally just added multiple times to the same delegate and that's why it was being called multiple times. That was a regrettable mistake and I have brought shame upon my people.


Also managed to fix the multiple matches issue. I had already fixed the issue with the matchgroup not being set (as I already stated) but I was relying on gamesparks to start the match. Apparently when you use CreatePendingMatch and supply a group of players it results in multiple match instances being created with the players connected to all of them.. don't really know why this is happening.

I changed it to manually starting a pending match for each player and the connecting the pending match of each player to the server's pending match. That did the trick. 


Thanks for the help.

Login to post a comment