summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/io/networked_multiplayer_peer.cpp11
-rw-r--r--core/io/networked_multiplayer_peer.h19
2 files changed, 20 insertions, 10 deletions
diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp
index 79f3e129e1..851064b6e8 100644
--- a/core/io/networked_multiplayer_peer.cpp
+++ b/core/io/networked_multiplayer_peer.cpp
@@ -12,15 +12,18 @@ void NetworkedMultiplayerPeer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("poll"), &NetworkedMultiplayerPeer::poll );
-
- BIND_CONSTANT( TARGET_ALL_PEERS );
+ 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 );
- ADD_SIGNAL( MethodInfo("peer_connected",PropertyInfo(Variant::INT,"id")));
- ADD_SIGNAL( MethodInfo("peer_disconnected",PropertyInfo(Variant::INT,"id")));
+ 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")));
}
NetworkedMultiplayerPeer::NetworkedMultiplayerPeer() {
diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h
index f140b57b8b..7071a52d7b 100644
--- a/core/io/networked_multiplayer_peer.h
+++ b/core/io/networked_multiplayer_peer.h
@@ -11,30 +11,37 @@ protected:
static void _bind_methods();
public:
- enum {
- TARGET_ALL_PEERS=0xFFFFFF // send to this for all peers
- };
-
enum TransferMode {
TRANSFER_MODE_UNRELIABLE,
TRANSFER_MODE_RELIABLE,
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(int p_peer)=0;
+ virtual void set_target_peer(const StringName& p_peer_id)=0;
virtual void set_channel(int p_channel)=0;
- virtual int get_packet_peer() const=0;
+ virtual StringName get_packet_peer() const=0;
virtual int get_packet_channel() const=0;
+ virtual bool is_server() 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