diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-08-20 12:49:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-20 12:49:15 +0200 |
commit | f2c9252b6ee51f7cffd2d7b99339164fb60f4c81 (patch) | |
tree | 73a47e680d58ccf437af61a9cd8ee4317801d339 | |
parent | a1aeeb34d0ae0d52806477eeb2d05c29d2fa2b68 (diff) | |
parent | d1539db2c6e42b4425adb8f8373eda155bc8b735 (diff) |
Merge pull request #31483 from Faless/ws/fix_double_relay
Fix WebSocketServer relaying message twice.
-rw-r--r-- | modules/websocket/websocket_multiplayer_peer.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index 362a1ebe0b..dd86c758bf 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -299,8 +299,6 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, u ERR_FAIL_COND(type != SYS_NONE); // Only server sends sys messages ERR_FAIL_COND(from != p_peer_id); // Someone is cheating - _server_relay(from, to, in_buffer, size); // Relay if needed - if (to == 1) { // This is for the server _store_pkt(from, to, in_buffer, data_size); @@ -315,13 +313,9 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, u // All but one, for us if not excluded if (_peer_id != -(int32_t)p_peer_id) _store_pkt(from, to, in_buffer, data_size); - - } else { - - // Send to specific peer - ERR_FAIL_COND(!_peer_map.has(to)); - get_peer(to)->put_packet(in_buffer, size); } + // Relay if needed (i.e. "to" includes a peer that is not the server) + _server_relay(from, to, in_buffer, size); } else { |