R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
IMatchmakingService.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** Created by hugo on 06/12/2025
4** File description:
5** IMatchmakingService.hpp
6*/
7
8#pragma once
9
10#include <cstdint>
11#include <functional>
12#include <memory>
13#include <vector>
14
15namespace server {
16 class Room;
17
23 using MatchCreatedCallback = std::function<void(std::shared_ptr<Room>)>;
24
30 public:
31 virtual ~IMatchmakingService() = default;
32
37 virtual void addPlayer(uint32_t playerId) = 0;
38
43 virtual void removePlayer(uint32_t playerId) = 0;
44
49 virtual void tick() = 0;
50
55 virtual size_t getQueueSize() const = 0;
56
62
76 virtual std::pair<std::shared_ptr<Room>, bool> findOrCreateMatch(
77 uint32_t playerId, const std::vector<std::shared_ptr<Room>> &availableRooms,
78 bool allowSpectator = true) = 0;
79 };
80
81} // namespace server
Interface for a matchmaking system.
virtual std::pair< std::shared_ptr< Room >, bool > findOrCreateMatch(uint32_t playerId, const std::vector< std::shared_ptr< Room > > &availableRooms, bool allowSpectator=true)=0
Find an available room or add player to matchmaking queue.
virtual void setMatchCreatedCallback(MatchCreatedCallback callback)=0
Set callback for when a match is created.
virtual void tick()=0
Process matchmaking queue and create matches Called periodically by the server.
virtual size_t getQueueSize() const =0
Get the number of players waiting in queue.
virtual void removePlayer(uint32_t playerId)=0
Remove a player from the matchmaking queue.
virtual ~IMatchmakingService()=default
virtual void addPlayer(uint32_t playerId)=0
Add a player to the matchmaking queue.
std::function< void(std::shared_ptr< Room >)> MatchCreatedCallback
Callback invoked when a match is created.