Skip to content

1008 feature request add a endpoint to allows players to leave a matchmaking room they have previously joined - #1012

Merged
tickBit merged 10 commits into
devfrom
1008-feature-request-add-a-endpoint-to-allows-players-to-leave-a-matchmaking-room-they-have-previously-joined
Sep 30, 2026
Merged

tickBit merged 10 commits into
devfrom
1008-feature-request-add-a-endpoint-to-allows-players-to-leave-a-matchmaking-room-they-have-previously-joined

Conversation

@tickBit

@tickBit tickBit commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Brief description

Related issue #1008

Adds support for authenticated players to leave their current matchmaking room. Room ownership, matchmaking state, Redis data, bot fillers, and MQTT room updates are handled according to the remaining room composition.

Change list

  • Added POST /matchmaking/rooms/leave.
  • Resolves the player’s active room without requiring a room ID.
  • Returns NOT_FOUND when the player has no active room.
  • Cleans up stale player-to-room Redis indexes.
  • Prevents leaving a room after it reaches MATCHED status.
  • Removes the departing player from the room and Redis index.
  • Transfers ownership when the room owner leaves.
  • Recalculates bot fillers and the room’s OPEN or READY status.
  • Removes updated rooms from the matchmaking queue when necessary.
  • Deletes the room when its last player leaves.
  • Sends ROOM_UPDATED notifications to the remaining players.
  • Added service tests for successful, edge, and error scenarios.
  • Updated the matchmaking API documentation.

@codecov-alt

codecov-alt Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.29730% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/matchmaking/matchmaking.service.ts 97.29% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/matchmaking/matchmaking.service.ts 86.18% <97.29%> (+1.07%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…-players-to-leave-a-matchmaking-room-they-have-previously-joined

@CapoMK25 CapoMK25 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on the code side, solid work.

Is this tested via Postman/in-memory testing or something along those lines? The description didn't say, or I missed it.

@tickBit

tickBit commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

Tests inside the code are the only tests this PR has been put through.

@CapoMK25

Copy link
Copy Markdown
Collaborator

Then this should be tested via Postman/Bruno/along those lines as the last step, as otherwise the frontend might flag something in the future that's not visible here.

@tickBit

tickBit commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator Author

Ok, I will do it tomorrow at the latest. If I find the time to it, I will test this via command line and with Postman tonight later.

…o-leave-a-matchmaking-room-they-have-previously-joined' of https://github.com/Alt-Org/Altzone-Server into 1008-feature-request-add-a-endpoint-to-allows-players-to-leave-a-matchmaking-room-they-have-previously-joined
@tickBit

tickBit commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator Author

Everything seemed to work fine, except the returned status code after leaving a matchmaking room was Nest's default: 201.

Now leaving room explicitly returns 204.

Here's testing output:

  1. Player A creates a matchmaking room.

  2. Player B joins the room:

{
    "data": {
        "Object": {
            "id": "6abcb0eef5f6cb874e0f8577",
            "matchType": "RANDOM",
            "gameType": 1,
            "status": "READY",
            "ownerPlayerId": "69ef8b7332f46bd743f4c54e",
            "players": [
                "69ef8b7332f46bd743f4c54e",
                "69f485c5fbe1d439c999ac6a"
            ],
            "bots": [],
            "teamSize": 2,
            "allowBots": true,
            "createdAt": "2026-09-30T06:49:18.402Z",
            "updatedAt": "2026-09-30T06:50:19.179Z",
            "readyAt": "2026-09-30T06:49:18.402Z"
        }
    },
    "metaData": {
        "dataKey": "Object",
        "modelName": "Object",
        "dataType": "Object",
        "dataCount": 2
    }
}
  1. Player B calls POST /matchmaking/rooms/leave -> 204

  2. Player B calls GET matchmaking/rooms

{
    "data": {
        "Object": []
    },
    "metaData": {
        "dataKey": "Object",
        "modelName": "Object",
        "dataType": "Array",
        "dataCount": 0
    }
}

Player A can still see the room:

{
    "data": {
        "Object": [
            {
                "id": "6abcb0eef5f6cb874e0f8577",
                "matchType": "RANDOM",
                "gameType": 1,
                "status": "READY",
                "ownerPlayerId": "69ef8b7332f46bd743f4c54e",
                "players": [
                    "69ef8b7332f46bd743f4c54e"
                ],
                "bots": [
                    {
                        "botId": "6abcb0eef5f6cb874e0f8577:bot:1",
                        "displayName": "Bot 1",
                        "isBot": true
                    }
                ],
                "teamSize": 2,
                "allowBots": true,
                "createdAt": "2026-09-30T06:49:18.402Z",
                "updatedAt": "2026-09-30T06:51:44.511Z",
                "readyAt": "2026-09-30T06:49:18.402Z"
            }
        ]
    },
...
}

@tickBit

tickBit commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator Author

I also tested, that when the player who has created a matchmaking room leaves the room, the other player can still be in the room:

{
    "data": {
        "Object": {
            "id": "6abcbba14114abfb2d61aa33",
            "matchType": "RANDOM",
            "gameType": 1,
            "status": "READY",
            "ownerPlayerId": "69f485c5fbe1d439c999ac6a",
            "players": [
                "69f485c5fbe1d439c999ac6a"
            ],
            "bots": [
                {
                    "botId": "6abcbba14114abfb2d61aa33:bot:1",
                    "displayName": "Bot 1",
                    "isBot": true
                }
            ],
            "teamSize": 2,
            "allowBots": true,
            "createdAt": "2026-09-30T07:34:57.744Z",
            "updatedAt": "2026-09-30T07:36:14.161Z",
            "readyAt": "2026-09-30T07:34:57.744Z"
        }
    },
    "metaData": {
        "dataKey": "Object",
        "modelName": "Object",
        "dataType": "Object",
        "dataCount": 2
    }
}

This is related to updating the state of the matchmaking room after leaving.

@tickBit

tickBit commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

Since the only additions after yesterday's approval are @HttpCode(HttpStatus.NO_CONTENT) and the two imports related to it in matchmaking.controller.ts and that change works and does not break anything, I will now merge this myself. Edit: The merge button is green to me.

I'll continue with merge dev into main for September then.

@tickBit
tickBit merged commit a939c5b into dev Sep 30, 2026
5 checks passed
@tickBit
tickBit deleted the 1008-feature-request-add-a-endpoint-to-allows-players-to-leave-a-matchmaking-room-they-have-previously-joined branch September 30, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Feature request: Add a endpoint to allows players to leave a matchmaking room they have previously joined.

2 participants