Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
Messaging.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Actions.hpp"
5
6#include <cstddef>
7#include <cstdint>
8#include <memory>
9#include <functional>
10#include <string_view>
11
12namespace monopoly::messaging
13{
14 inline constexpr std::size_t MessageQueueCapacity =
15 (rules::MaxPlayers * 3) +
17
18 bool initialize();
19 void shutdown();
20
21 // Call after local startup and before the first game cycle. A connecting
22 // client is never a RULE server, even before/after its connection is live.
23 bool startNetwork(std::unique_ptr<Transport> transport);
24 void pumpNetwork();
25 void stopNetwork();
26 void setNetworkStarter(std::function<bool()> starter);
28 [[nodiscard]] bool gameplayNetwork();
29 [[nodiscard]] bool gameplayReady();
32 void resetPlayerOwners();
33 void setPlayerOwner(rules::PlayerNumber player, std::uint32_t source);
34 [[nodiscard]] std::uint32_t playerOwner(rules::PlayerNumber player);
36 const actions::Message& message);
37 [[nodiscard]] std::string_view networkError();
38
39 bool sendAction(const actions::Message& message);
40
41 bool sendAction(
42 actions::Type action,
43 rules::PlayerNumber fromPlayer,
44 rules::PlayerNumber toPlayer,
45 std::int64_t numberA = 0,
46 std::int64_t numberB = 0,
47 std::int64_t numberC = 0,
48 std::int64_t numberD = 0,
49 std::wstring_view stringA = {}
50 );
51
52 void clearActionQueue();
53
54 std::size_t currentQueueSize();
55 bool receiveAction(actions::Message& message);
57
58 bool serverMode();
59 bool networkMode();
60
61 std::size_t queuedActionCount();
62}
63
64
std::shared_ptr< const data::HmdTextureImage > source
unsigned state
unsigned index
bool receiveAction(actions::Message &message)
bool startConfiguredNetwork()
std::size_t currentQueueSize()
bool consumeHostDisconnected()
std::size_t queuedActionCount()
std::string_view networkError()
constexpr std::size_t MessageQueueCapacity
Definition Messaging.hpp:14
bool authenticSender(const rules::GameState &state, const actions::Message &message)
Definition Messaging.cpp:88
bool startNetwork(std::unique_ptr< Transport > transport)
void setNetworkStarter(std::function< bool()> starter)
std::uint32_t playerOwner(rules::PlayerNumber player)
Definition Messaging.cpp:83
bool sendAction(const actions::Message &message)
void noteClientResynchronized()
void setPlayerOwner(rules::PlayerNumber player, std::uint32_t source)
Definition Messaging.cpp:76
bool receiveVoiceChatOnly(actions::Message &message)
std::uint8_t PlayerNumber
Definition RuleTypes.hpp:12
constexpr std::size_t SquareCount
Definition RuleTypes.hpp:24
constexpr PlayerNumber MaxPlayers
Definition RuleTypes.hpp:14