Files
bloubloulespoissons/Network/networking_client.h
Félix MARQUET 1343fe01e7 fix: corrige la visibilité des autres joueurs en multijoueur
- Ajout de la méthode `getPlayerId` const dans `player.cpp` et `player.h`.
- Ajout de la fonction `receivePlayerListFromServer` et `addPlayerToGame` dans `networking_client.cpp` et `networking_client.h`.
- Correction de la fonction `sendPlayerListToNewClient` et `getAllPlayers` dans `networking.cpp` et `networking.h`.
- Ajout de l'affichage des joueurs proches en mode multijoueur dans `utility.cpp` et `utility.h`.
2024-12-18 15:31:51 +01:00

29 lines
762 B
C++

//
// Created by BreizhHardware on 04/12/2024.
//
#ifndef NETWORKING_CLIENT_H
#define NETWORKING_CLIENT_H
#include <SDL2/SDL_net.h>
#include <iostream>
#include <sstream>
#include <thread>
#include <chrono>
#include "../Utility/env.h"
#include "../Entities/player.h"
class Player;
inline TCPsocket client;
bool initClient(IPaddress& ip, const char* host, int port);
void closeClient();
void sendMessage(TCPsocket socket, const std::string& message);
std::string receiveMessage(TCPsocket socket);
void handleClientMessage(Player& player);
void sendKeepAlive(TCPsocket serverSocket);
void startKeepAlive(TCPsocket serverSocket);
void receivePlayerListFromServer(int serverSocket);
void addPlayerToGame(int playerId, int x, int y);
#endif //NETWORKING_CLIENT_H