diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-08-27 02:11:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-27 02:11:30 +0200 |
commit | 6e7f0190ee6d49f4f1059882b18430d947e0fe48 (patch) | |
tree | 513fb0419cca7df53d52f93e3dae287b11c31bfa /scene | |
parent | 612099e3771578fd3e78171f1ca1444f6c41cef3 (diff) | |
parent | 7c802837a384f589b8448c3777ed3c0aa2da189d (diff) |
Merge pull request #10579 from quinnyo/rpc-sender-id
Method to get ID of RPC calling peer
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/scene_tree.cpp | 9 | ||||
-rw-r--r-- | scene/main/scene_tree.h | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 33331a465f..99af8face0 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1708,6 +1708,11 @@ Vector<int> SceneTree::get_network_connected_peers() const { return ret; } + +int SceneTree::get_rpc_sender_id() const { + return rpc_sender_id; +} + void SceneTree::set_refuse_new_network_connections(bool p_refuse) { ERR_FAIL_COND(!network_peer.is_valid()); network_peer->set_refuse_new_connections(p_refuse); @@ -2102,7 +2107,9 @@ void SceneTree::_network_poll() { ERR_PRINT("Error getting packet!"); } + rpc_sender_id = sender; _network_process_packet(sender, packet, len); + rpc_sender_id = 0; if (!network_peer.is_valid()) { break; //it's also possible that a packet or RPC caused a disconnection, so also check here @@ -2182,6 +2189,7 @@ void SceneTree::_bind_methods() { ClassDB::bind_method(D_METHOD("has_network_peer"), &SceneTree::has_network_peer); ClassDB::bind_method(D_METHOD("get_network_connected_peers"), &SceneTree::get_network_connected_peers); ClassDB::bind_method(D_METHOD("get_network_unique_id"), &SceneTree::get_network_unique_id); + ClassDB::bind_method(D_METHOD("get_rpc_sender_id"), &SceneTree::get_rpc_sender_id); ClassDB::bind_method(D_METHOD("set_refuse_new_network_connections", "refuse"), &SceneTree::set_refuse_new_network_connections); ClassDB::bind_method(D_METHOD("is_refusing_new_network_connections"), &SceneTree::is_refusing_new_network_connections); ClassDB::bind_method(D_METHOD("_network_peer_connected"), &SceneTree::_network_peer_connected); @@ -2266,6 +2274,7 @@ SceneTree::SceneTree() { call_lock = 0; root_lock = 0; node_count = 0; + rpc_sender_id = 0; //create with mainloop diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index c62607244e..1de9a2ce8c 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -199,6 +199,8 @@ private: void _connection_failed(); void _server_disconnected(); + int rpc_sender_id; + //path sent caches struct PathSentCache { Map<int, bool> confirmed_peers; @@ -445,6 +447,7 @@ public: bool has_network_peer() const; int get_network_unique_id() const; Vector<int> get_network_connected_peers() const; + int get_rpc_sender_id() const; void set_refuse_new_network_connections(bool p_refuse); bool is_refusing_new_network_connections() const; |