generated from Persson-dev/Godot-Xmake
moved network interface
This commit is contained in:
38
include/blitz/godot/NetworkInterface.h
Normal file
38
include/blitz/godot/NetworkInterface.h
Normal 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
|
||||
Reference in New Issue
Block a user