File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ namespace Constants {
4+
5+ inline constexpr int PORT = 8080 ;
6+ inline constexpr int MAX_BUFFER_SIZE = 1024 ;
7+
8+ } // namespace Constants
Original file line number Diff line number Diff line change 1212#include < string>
1313
1414#include " constants/game_constants.h"
15+ #include " constants/network_constants.h"
1516#include " core/window.h"
1617#include " entities/actions/npc_movement_handler.h"
1718#include " entities/actions/player_input_handler.h"
@@ -129,8 +130,7 @@ void Game::Update() {
129130 client_->Send (msg.c_str (), msg.size ());
130131
131132 // TODO(ramirezfernando): Receive updated other player state from server.
132- constexpr size_t maxBufferSize = 1024 ;
133- std::array<char , maxBufferSize> buf{};
133+ std::array<char , Constants::MAX_BUFFER_SIZE > buf{};
134134 const ssize_t n = client_->Receive (buf.data (), buf.size ());
135135 if (n > 0 ) {
136136 buf.at (static_cast <size_t >(n)) = ' \0 ' ;
Original file line number Diff line number Diff line change 99#include < memory>
1010#include < string>
1111
12+ #include " constants/network_constants.h"
13+
1214int main () {
13- auto server = std::unique_ptr<Server>(Server::Create (" 8080" ));
15+ auto server =
16+ std::unique_ptr<Server>(Server::Create (std::to_string (Constants::PORT )));
1417
15- constexpr size_t maxBufferSize = 1024 ;
16- std::array<char , maxBufferSize> buf{};
18+ std::array<char , Constants::MAX_BUFFER_SIZE > buf{};
1719 sockaddr_storage peer{};
18- socklen_t peer_len = sizeof (peer); // Will be updated by ReceiveFrom.
20+ socklen_t peer_len = sizeof (peer);
1921
2022 while (true ) {
2123 const ssize_t n =
You can’t perform that action at this time.
0 commit comments