Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
MessageTransport.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Actions.hpp"
4
5#include <cstddef>
6#include <cstdint>
7#include <string_view>
8
10{
11 // Owned and polled by MESS on the game thread. No callback may touch RULE
12 // or the audio backend from a socket thread. The transport assigns
13 // sourceId from the connection, never from a client-supplied action field.
15 {
16 public:
17 virtual ~Transport() = default;
18 virtual void pump() = 0;
19 virtual bool receive(actions::Message& message) = 0;
20 virtual bool send(const actions::Message& message) = 0;
21 [[nodiscard]] virtual bool server() const noexcept = 0;
23 [[nodiscard]] virtual std::size_t queued() const noexcept = 0;
25 // Optional gameplay extension. MESS owns and validates slot ownership;
26 // this table is its transport routing projection, never client input.
27 virtual void setPlayerOwner(rules::PlayerNumber, std::uint32_t) noexcept {}
28 virtual bool admitSource(std::uint32_t) { return true; }
29 virtual bool sendToSource(const actions::Message&, std::uint32_t) { return false; }
30 virtual bool receiveDisconnectedSource(std::uint32_t&) { return false; }
31 [[nodiscard]] virtual bool sourceConnected(std::uint32_t) const noexcept { return false; }
32 [[nodiscard]] virtual std::uint32_t localSourceId() const noexcept { return 0; }
33 [[nodiscard]] virtual bool gameplayEnabled() const noexcept { return false; }
34 };
35}
unsigned index
virtual bool receiveDisconnectedSource(std::uint32_t &)
virtual bool receive(actions::Message &message)=0
virtual void setPlayerOwner(rules::PlayerNumber, std::uint32_t) noexcept
virtual bool gameplayEnabled() const noexcept
virtual bool server() const noexcept=0
virtual bool sourceConnected(std::uint32_t) const noexcept
virtual bool sendToSource(const actions::Message &, std::uint32_t)
virtual std::uint32_t localSourceId() const noexcept
virtual std::size_t queued() const noexcept=0
virtual ~Transport()=default
virtual bool send(const actions::Message &message)=0
virtual std::string_view error() const noexcept=0
virtual bool admitSource(std::uint32_t)
virtual bool active() const noexcept=0