summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-08-19 16:48:08 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-08-19 16:48:41 -0300
commit1add52b55e038a4fa789c64f3919f7fcab808e91 (patch)
treedd7878449dd1d2301684a5e5aa34b8466744b168 /core/io
parent56fa741b7a729bd5a00cff17e4382af547de92ad (diff)
Brand new networked multiplayer
Diffstat (limited to 'core/io')
-rw-r--r--core/io/networked_multiplayer_peer.cpp17
-rw-r--r--core/io/networked_multiplayer_peer.h17
2 files changed, 25 insertions, 9 deletions
diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp
index 851064b6e8..a771ba06b7 100644
--- a/core/io/networked_multiplayer_peer.cpp
+++ b/core/io/networked_multiplayer_peer.cpp
@@ -5,14 +5,16 @@ void NetworkedMultiplayerPeer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_transfer_mode","mode"), &NetworkedMultiplayerPeer::set_transfer_mode );
ObjectTypeDB::bind_method(_MD("set_target_peer","id"), &NetworkedMultiplayerPeer::set_target_peer );
- ObjectTypeDB::bind_method(_MD("set_channel","id"), &NetworkedMultiplayerPeer::set_channel );
ObjectTypeDB::bind_method(_MD("get_packet_peer"), &NetworkedMultiplayerPeer::get_packet_peer );
- ObjectTypeDB::bind_method(_MD("get_packet_channel"), &NetworkedMultiplayerPeer::get_packet_channel );
ObjectTypeDB::bind_method(_MD("poll"), &NetworkedMultiplayerPeer::poll );
ObjectTypeDB::bind_method(_MD("get_connection_status"), &NetworkedMultiplayerPeer::get_connection_status );
+ ObjectTypeDB::bind_method(_MD("get_unique_id"), &NetworkedMultiplayerPeer::get_unique_id );
+
+ ObjectTypeDB::bind_method(_MD("set_refuse_new_connections","enable"), &NetworkedMultiplayerPeer::set_refuse_new_connections );
+ ObjectTypeDB::bind_method(_MD("is_refusing_new_connections"), &NetworkedMultiplayerPeer::is_refusing_new_connections );
BIND_CONSTANT( TRANSFER_MODE_UNRELIABLE );
BIND_CONSTANT( TRANSFER_MODE_RELIABLE );
@@ -22,8 +24,15 @@ void NetworkedMultiplayerPeer::_bind_methods() {
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")));
+ BIND_CONSTANT( TARGET_PEER_BROADCAST );
+ BIND_CONSTANT( TARGET_PEER_SERVER );
+
+
+ ADD_SIGNAL( MethodInfo("peer_connected",PropertyInfo(Variant::INT,"id")));
+ ADD_SIGNAL( MethodInfo("peer_disconnected",PropertyInfo(Variant::INT,"id")));
+ ADD_SIGNAL( MethodInfo("server_disconnected"));
+ ADD_SIGNAL( MethodInfo("connection_succeeded") );
+ ADD_SIGNAL( MethodInfo("connection_failed") );
}
NetworkedMultiplayerPeer::NetworkedMultiplayerPeer() {
diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h
index 7071a52d7b..1c39096ab5 100644
--- a/core/io/networked_multiplayer_peer.h
+++ b/core/io/networked_multiplayer_peer.h
@@ -11,6 +11,10 @@ protected:
static void _bind_methods();
public:
+ enum {
+ TARGET_PEER_BROADCAST=0,
+ TARGET_PEER_SERVER=1
+ };
enum TransferMode {
TRANSFER_MODE_UNRELIABLE,
TRANSFER_MODE_RELIABLE,
@@ -25,17 +29,20 @@ public:
virtual void set_transfer_mode(TransferMode p_mode)=0;
- virtual void set_target_peer(const StringName& p_peer_id)=0;
- virtual void set_channel(int p_channel)=0;
-
+ virtual void set_target_peer(int p_peer_id)=0;
- virtual StringName get_packet_peer() const=0;
- virtual int get_packet_channel() const=0;
+ virtual int get_packet_peer() const=0;
virtual bool is_server() const=0;
virtual void poll()=0;
+ virtual int get_unique_id() const=0;
+
+ virtual void set_refuse_new_connections(bool p_enable)=0;
+ virtual bool is_refusing_new_connections() const=0;
+
+
virtual ConnectionStatus get_connection_status() const=0;
NetworkedMultiplayerPeer();