Multiplayer Server: Match Making Server

  

The Match Making server code that comes with this plugin is a room type used to match 2 or more players that have the same Player Data properties passed to the room on connection. When you connect to a room you will notice that there is an option to pass player data. Pass a Data Container component with properties that should match two or more players. Only the players waiting for a match with the exact same values will be paired together.

There is one key word property that you should pass if you want to restrict how many players are matched to each room. Make sure to pass a property called "MaxPlayers". This property name is case sensitive. If this property is present when a player connects to the "MatchMakingServer" room type then the server will make sure and remove a room from the match queue once the max amount of players have been matched to that room. The room type is important because it is needed to let the action know what type of room to connect to, so take not of it.

Event Descriptions

There are a number of unique events that get fired from the Match Making server with or without information attached.

"MatchCreated" - This event gets fired whenever a new match room is created. The server creates a unique room id and passes that id back with this event. This indicates that the player is the creator of the matched room. Once this event is returned you can disconnect from the match making room and connect to the private matched room with the id that is returned. Only the players that were matched will know the id of this newly matched room.

"MatchFound" - This event is fired whenever a new player is matched up with another player. The unique room id is passed with this event. Make sure to listen for both MatchCreated and Match Joined because the first player added to a matched room will not receive this event. Once this event is returned you can disconnect from the match making room and connect to the private matched room with the id that is returned. Only the players that were matched will know the id of this newly matched room.

"RoomEntered" - This event is fired once the player connecting to the room as successfully entered the room and it also returns the current logged in players' username. This is great for knowing which player is the current player when looking through the player list that is returned from the server.

"PlayerList" - This event will return a list of all the players currently connected to the room. Every time a player enters or leaves the room this event gets fired from the server. Use a List Data component to store the list of player usernames that gets returned with this event.

"PlayerJoined" - This event gets fired to all the other players already connected to a room when a new player joins. This is how you will know if you need to create a new object on all the other players' screen if a new player joins, for example a poker table with a new player that joins. The new players username is passed with this event. Keep in mind that only the other players in the room will receive this event not the new player connecting. You will notice in multiplayer tile demo that this event is listened to so that all existing player pieces can tell the new player that they already exist and pass the new player their current state. This is a good way to update the new player of the current state of the game.

"PlayerLeft" - This event gets fired when a player leaves the room.

Room Type name - "MatchMakingServer"

Follow Us For Updates