summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp12
-rw-r--r--modules/enet/networked_multiplayer_enet.h4
2 files changed, 13 insertions, 3 deletions
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 64f08a90ef..aebdfe03a5 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -81,6 +81,8 @@ Error NetworkedMultiplayerENet::create_client(const IP_Address& p_ip,int p_port,
//technically safe to ignore the peer or anything else.
connection_status=CONNECTION_CONNECTING;
+ active=true;
+ server=false;
return OK;
}
@@ -144,7 +146,13 @@ void NetworkedMultiplayerENet::poll(){
}
}
-void NetworkedMultiplayerENet::disconnect() {
+bool NetworkedMultiplayerENet::is_server() const {
+ ERR_FAIL_COND_V(!active,false);
+
+ return server;
+}
+
+void NetworkedMultiplayerENet::close_connection() {
ERR_FAIL_COND(!active);
@@ -258,6 +266,6 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet(){
NetworkedMultiplayerENet::~NetworkedMultiplayerENet(){
if (active) {
- disconnect();
+ close_connection();
}
}
diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h
index 20eb53990d..ec6b084d66 100644
--- a/modules/enet/networked_multiplayer_enet.h
+++ b/modules/enet/networked_multiplayer_enet.h
@@ -52,10 +52,12 @@ public:
Error create_server(int p_port, int p_max_clients=32, int p_max_channels=1, int p_in_bandwidth=0, int p_out_bandwidth=0);
Error create_client(const IP_Address& p_ip,int p_port, int p_max_channels=1, int p_in_bandwidth=0, int p_out_bandwidth=0);
- void disconnect();
+ void close_connection();
virtual void poll();
+ virtual bool is_server() const;
+
virtual int get_available_packet_count() const;
virtual Error get_packet(const uint8_t **r_buffer,int &r_buffer_size) const; ///< buffer is GONE after next get_packet
virtual Error put_packet(const uint8_t *p_buffer,int p_buffer_size);