From 01bdfe1ff6033c012d0833ee165f6055fed69724 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 14 Aug 2016 14:06:51 -0300 Subject: Missing some bits, and added connection status. --- core/io/networked_multiplayer_peer.cpp | 5 +++++ core/io/networked_multiplayer_peer.h | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'core/io') diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp index f172fef570..851064b6e8 100644 --- a/core/io/networked_multiplayer_peer.cpp +++ b/core/io/networked_multiplayer_peer.cpp @@ -12,11 +12,16 @@ void NetworkedMultiplayerPeer::_bind_methods() { ObjectTypeDB::bind_method(_MD("poll"), &NetworkedMultiplayerPeer::poll ); + ObjectTypeDB::bind_method(_MD("get_connection_status"), &NetworkedMultiplayerPeer::get_connection_status ); BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE ); BIND_CONSTANT( TRANSFER_MODE_RELIABLE ); BIND_CONSTANT( TRANSFER_MODE_ORDERED ); + BIND_CONSTANT( CONNECTION_DISCONNECTED ); + BIND_CONSTANT( CONNECTION_CONNECTING ); + BIND_CONSTANT( CONNECTION_CONNECTED ); + ADD_SIGNAL( MethodInfo("peer_connected",PropertyInfo(Variant::STRING,"id"))); ADD_SIGNAL( MethodInfo("peer_disconnected",PropertyInfo(Variant::STRING,"id"))); } diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h index 535f20f199..d8143b02c0 100644 --- a/core/io/networked_multiplayer_peer.h +++ b/core/io/networked_multiplayer_peer.h @@ -17,6 +17,12 @@ public: TRANSFER_MODE_ORDERED }; + enum ConnectionStatus { + CONNECTION_DISCONNECTED, + CONNECTION_CONNECTING, + CONNECTION_CONNECTED, + }; + virtual void set_transfer_mode(TransferMode p_mode)=0; virtual void set_target_peer(const StringName& p_peer_id)=0; @@ -26,12 +32,14 @@ public: virtual StringName get_packet_peer() const=0; virtual int get_packet_channel() const=0; - virtual void poll()=0; + virtual ConnectionStatus get_connection_status() const=0; + NetworkedMultiplayerPeer(); }; VARIANT_ENUM_CAST( NetworkedMultiplayerPeer::TransferMode ) +VARIANT_ENUM_CAST( NetworkedMultiplayerPeer::ConnectionStatus ) #endif // NetworkedMultiplayerPeer_H -- cgit v1.2.3