Create multiplayer experiences

There's nothing quite as thrilling as a multiplayer game. Learn how you can make the most our multiplayer games.

Types of games

Not all Gamezop games support multiplayer experiences. Here is a list of our games on which you can create real-time multiplayer experiences for your users.

There are 2 types of multiplayer games:

When you open any game url that you receive on our All Games API, the game opens a single-player experience by default.

To enable a multiplayer experience, you need to follow these steps:

Generate a roomDetails object

This carries all the details we need to create a match between your users. roomDetails is a JSON object with the following values:

Base64 encode the object

Let's assume this is the final roomDetails object you've generated and you now want to encode it:

{
        roomId: "ABC01", 
        user: {
                name: "John Doe",
                photo: "https://example.com/photos/user-1.jpg",
                sub: "xyz-123"
        },
        maxPlayers: 4,
        minPlayers: 2,
        maxWait: 60,
        rounds: 1,
        cta: "BRIDGE.updateState",
        text: "go_home",
        allowBots: false
}

If you're using Javascript, store this in a const named roomDetails, and then run:

encodeURIComponent(btoa(JSON.stringify(roomDetails)));

You'll get the following value:

eyJyb29tSWQiOiJBQkMwMSIsInVzZXIiOnsibmFtZSI6IkpvaG4gRG9lIiwicGhvdG8iOiJodHRwczovL2V4YW1wbGUuY29tL3Bob3Rvcy91c2VyLTEuanBnIiwic3ViIjoieHl6LTEyMyJ9LCJtYXhQbGF5ZXJzIjo0LCJtaW5QbGF5ZXJzIjoyLCJtYXhXYWl0Ijo2MCwicm91bmRzIjoxLCJjdGEiOiJCUklER0UudXBkYXRlU3RhdGUiLCJ0ZXh0IjoiZ29faG9tZSIsImFsbG93Qm90cyI6ZmFsc2V9

Create the multiplayer game url

If you are going to send user details or a wide variety of roomId values, you may need to generate the final game link on the client instead of the server. If you aren't using those values, then you can manually generate a link and send all your users to the same link and they will keep getting matched with one other.

Generating the link is extremly simple. Once you have the encoded roomDetails value, just append it to the URL you receive from the All Games API. The final URL will be of the following structure:

{url-from-All-Games-API} ?roomDetails= {encoded-object}

Get multiple users to open the multiplayer game together

Once you've set up the system to generate these links, you need to have multiple users from your platform open the links together. When a user opens one of these links, our matchmaking module tries to find other users from your Property ID with the same roomId, and matches the users together in a multiplayer experience.

Receive data on match winners

In case you want a callback with details of the winners at the end of each match, you will have to provide 2 APIs for it. Detailed here.

Last updated