mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-02-20 00:04:23 -05:00
Replace POSIX-specific socket and process APIs with portable abstractions so the project builds on both Windows and Linux. - Add include/network/net_platform.hpp: Winsock2/POSIX socket abstraction (socket types, non-blocking, error handling, WSAStartup lifecycle) - Add include/platform/process.hpp: CreateProcess/fork+exec abstraction for spawning ffplay subprocesses - Update network module (tcp_socket, world_socket) to use portable socket helpers instead of raw POSIX calls - Update audio module (music_manager, footstep_manager, activity_sound_manager) to use portable process helpers instead of fork/exec/kill/waitpid - Replace hardcoded /tmp/ paths with std::filesystem::temp_directory_path() - Link ws2_32 and SDL2main on Windows in CMakeLists.txt
32 lines
682 B
C++
32 lines
682 B
C++
#pragma once
|
|
|
|
#include "network/socket.hpp"
|
|
#include "network/net_platform.hpp"
|
|
|
|
namespace wowee {
|
|
namespace network {
|
|
|
|
class TCPSocket : public Socket {
|
|
public:
|
|
TCPSocket();
|
|
~TCPSocket() override;
|
|
|
|
bool connect(const std::string& host, uint16_t port) override;
|
|
void disconnect() override;
|
|
bool isConnected() const override { return connected; }
|
|
|
|
void send(const Packet& packet) override;
|
|
void update() override;
|
|
|
|
private:
|
|
void tryParsePackets();
|
|
size_t getExpectedPacketSize(uint8_t opcode);
|
|
|
|
socket_t sockfd = INVALID_SOCK;
|
|
bool connected = false;
|
|
std::vector<uint8_t> receiveBuffer;
|
|
};
|
|
|
|
} // namespace network
|
|
} // namespace wowee
|