moved network interface

This commit is contained in:
2024-08-19 15:24:44 +02:00
parent 99ff2c4ac3
commit 10f91f4b19
14 changed files with 190 additions and 216 deletions

View File

@@ -0,0 +1,38 @@
#pragma once
#include <blitz/protocol/PacketDispatcher.h>
#include <blitz/protocol/Packets.h>
#include <godot_cpp/classes/node.hpp>
namespace blitz {
class NetworkInterface : public godot::Node, public protocol::PacketDispatcher {
GDCLASS(NetworkInterface, godot::Node)
protected:
static void _bind_methods();
public:
NetworkInterface();
~NetworkInterface();
void BroadcastPacket(const protocol::Packet& a_Packet);
void SendPacket(PeerID a_Peer, const protocol::Packet& a_Packet);
godot::Error JoinGame(const godot::String& a_Address, uint16_t a_Port);
godot::Error CreateGame(uint16_t a_Port, bool a_Dedicated = false);
void ShutdownNetwork();
void _ready() override;
private:
void RecievePacketDataReliable(godot::PackedByteArray a_PacketData);
void OnPlayerConnected(PeerID a_PeerId);
void OnPlayerDisconnected(PeerID a_PeerId);
void OnConnectOk();
void OnConnectFail();
void OnServerDisconnected();
};
} // namespace blitz