Help Solving a LAN Session issue

We are looking for some hints or ideas on how to solve an issue of getting 20 machines on a LAN to randomly pair up with another machine on the LAN at roughly the same time.

This is part of a University research project that involves anywhere from 4-20 people in a room, randomly connect to another person in the room so they can complete a level together, but not know who it is (kinda like Journey for the PS3)
We thought about ‘pre-connecting’ them all, by setting them up before the participants arrive, but unfortunately there will also be other software being run on the machines (laptops) for the experiment and we can’t have an Unreal app running in the background while that happens (it’s also a battery killer). So basically, as part of the experiment protocol, they will all be starting the app at the same time (give or take a few seconds).

Our plan, then, is to have half of the people in the room run an app that creates a session, and the other half connect to one of those sessions.

So far we’ve tried the following:
We have two builds, which differ only in one hard coded variable (isHost)
-The ‘Host’ build (isHost - True), when started, immediately creates a LAN session, chooses the level, and waits.
-The ‘Client’ build (isHost - False), when started, waits 10 seconds (to allow all the hosts to create their sessions), then runs the ‘Find Sessions’ function. It then looks through the array of sessions found, looking for a session with only one player connected. When it finds one, it joins the session.

This works, but unfortunately we sometimes get two clients and one host in a single session. It’s like there are two clients joining at the same time.
We tried limiting the number of ‘public connections’ to 2 (one for host, one for client) but it doesn’t seem to help. When we tried 1 public connection, it wouldn’t join at all.
(Does anyone know, as an aside, if the public connection parameter is supposed to include room for the ‘creator’ of the session… we can’t find any documentation to indicate yes or no?)

Anyway, does anyone have any ideas on how to solve our issue?

Thanks in advance.

Kick the last client out of the game is you detect there are already 2 players.

That’s a dirty solution but that might do the trick if you don’t find anything more elegant.

I always thought it would but oddly I never tried.

What you can try is doing a double-check when a player clicks a lobby to join a game:
I suppose you have a server entry widget that holds information about a net session. When a player clicks that widget, instead of simply trying to join, you find sessions (once again) and you try to find the session matching the one the player clicked. If you do find it, check if it’s full (or check how many players), if it is, just tell the client the game was full and do not join session. If it’s not full just go ahead as usual.

Thanks for the thought, Yun-Kin, we’ll see if we can implement a “kick-out” system…

As for your second suggestion, we don’t want the participants of our study to click to join a session, we need them to just “be” in a session when it starts up.
The idea is sound though. Have the client look for all sessions, pick one randomly, check to see if it’s still empty, then join.
Talking it out, though, there is still a chance the same thing could happen…

I really wish I could find more about the public connection parameter, I can’t tell if it’s being ignored, or if two clients are just managing to get join before the “parameter” closes the down.