Random matchmaking
It's also possible to employ a form of random matchmaking. That is, by supplying the special room ID "$service-room$" to CreateJoinRoom
, you will connect the user to so called "Service Rooms". A service room is a room with a randomly created ID, and a new room will only be created when the existing service rooms are all filled up to 75 percent (this gives some leeway to move users between rooms). By using CreateJoinRoom
, the client will create a room if it doesn't exist, or join the existing one if it does.
void OnGUI() { if( roomConnection != null ) return; if( GUILayout.Button( "Join Random", GUILayout.Width( 200f ) ) ) { client.Multiplayer.CreateJoinRoom( "$service-room$", "MyCode", true, null, null, delegate( Connection connection ) { Debug.Log( "Joining room" ); roomConnection = connection; }, delegate( PlayerIOError error ) { Debug.Log( error.Message ); } ); } if( GUILayout.Button( "Create...