mirror of
https://github.com/BreizhHardware/bloubloulespoissons.git
synced 2026-01-18 16:47:31 +01:00
- 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`.
29 lines
762 B
C++
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
|