Room-Based Games

Room-based games are the most common multiplayer game type. Players join specific rooms (lobbies, matches, sessions) identified by names or codes. When a match ends, players leave the room.

What Are Room-Based Games?

Room-based games include:

  • First-person shooters (COD, Valorant, Overwatch)
  • Battle royales (Fortnite, PUBG)
  • Party games (Mario Party, Fall Guys)
  • Sports games (FIFA, NBA 2K)
  • Competitive card games (Hearthstone)
  • Any game with matchmaking lobbies

How Invitations Work

Invitation Flow for Room-Based Games

  1. Host creates a room - Room is created with a name/code
  2. Host sends invitation - Selects a friend to invite
  3. Friend receives notification - Shows who invited them and to what room
  4. Friend joins room - Directly joins using the room name/code from invitation

RoomInfo Data

Room information is stored in the RoomInfo model:

PropertyDescription
RoomIdUnique identifier for the room
RoomNameDisplay name of the room (visible to players)
HostIdUser ID of the room host
MaxPlayersMaximum players allowed
CurrentPlayersCurrent player count
IsPrivateWhether the room requires a password
CustomPropertiesGame-specific metadata

Configuration

Setting Up Room-Based Games

  1. Set Default Game Type on FriendManager to RoomBased
  2. Configure RoomBasedGameTypeSettings if needed:
    • Default max players
    • Allow room listing
    • Room name constraints

Developer Details

RoomBasedGameTypeHandler

The RoomBasedGameTypeHandler handles all room-related operations:

// Create a room and prepare an invitation
_roomHandler.CreateSession("My Game Room", 4, customProperties, (success, roomInfo) => {
    if (success) {
        var invitation = _roomHandler.PrepareInvitation(
            targetUserId: "friend123",
            message: "Join my game!",
            customData: null
        );
        // Send the invitation
    }
});

// Handle incoming invitation to join
public void OnInvitationReceived(FriendInvitation invitation) {
    _roomHandler.JoinSession(invitation.RoomInfo, (success, error) => {
        if (success) {
            Debug.Log("Joined room!");
        }
    });
}