summaryrefslogtreecommitdiff
path: root/modules/webrtc/webrtc_multiplayer_peer.cpp
AgeCommit message (Collapse)Author
2022-10-28[MP] Add MultiplayerPeer disconnect_peer, close.Fabio Alessandrelli
Update ENet, WebRTC, and WebSocket to support peer disconnection and unify the close function.
2022-10-27[MP] Let MultiplayerAPI handle packet relaying and peer signaling.Fabio Alessandrelli
MultiplayerPeer changes: - Adds is_server_relay_supported virtual method Informs the upper MultiplayerAPI layer if it can signal peers connected to the server to other clients, and perform packet relaying among them. - Adds get_packet_channel and get_packet_mode virtual methods Allows the MultiplayerAPI to retrieve the channel and transfer modes to use when relaying the last received packet. SceneMultiplayerPeer changes: - Implement peer signaling and packet relaying when the MultiplayerPeer advertise they are supported. ENet, WebRTC, WebSocket changes: - Removed custom code for relaying from WebSocket and ENet, and let it be handled by the upper layer. - Update WebRTC to split create_client, create_server, and create_mesh, with the latter behaving like the old initialize with "server_compatibility = false", and the first two supporting the upper layer relaying protocol.
2022-07-26[Net] Modularize multiplayer, expose MultiplayerAPI to extensions.Fabio Alessandrelli
- RPC configurations are now dictionaries. - Script.get_rpc_methods renamed to Script.get_rpc_config. - Node.rpc[_id] and Callable.rpc now return an Error. - Refactor MultiplayerAPI to allow extension. - New MultiplayerAPI.rpc method with Array argument (for scripts). - Move the default MultiplayerAPI implementation to a module.
2022-05-16Replace most uses of Map by HashMapreduz
* Map is unnecessary and inefficient in almost every case. * Replaced by the new HashMap. * Renamed Map to RBMap and Set to RBSet for cases that still make sense (order matters) but use is discouraged. There were very few cases where replacing by HashMap was undesired because keeping the key order was intended. I tried to keep those (as RBMap) as much as possible, but might have missed some. Review appreciated!
2022-03-04WebRTC: Fix potential nullptr dereference in error messageRémi Verschelde
This was evidently a typo. Didn't get a crash but GCC 12 raised a `-Warray-bounds` warning: ``` In file included from ./core/io/stream_peer.h:34, from ./core/io/packet_peer.h:34, from ./core/multiplayer/multiplayer_peer.h:34, from modules/webrtc/webrtc_multiplayer_peer.h:34, from modules/webrtc/webrtc_multiplayer_peer.cpp:31: In member function 'T* Ref<T>::operator->() [with T = WebRTCMultiplayerPeer::ConnectedPeer]', inlined from 'virtual Error WebRTCMultiplayerPeer::put_packet(const uint8_t*, int)' at modules/webrtc/webrtc_multiplayer_peer.cpp:376:4: ./core/object/ref_counted.h:101:24: error: array subscript 0 is outside array bounds of 'Ref<WebRTCMultiplayerPeer::ConnectedPeer> [0]' [-Werror=array-bounds] 101 | return reference; | ^~~~~~~~~ ```
2022-01-03Update copyright statements to 2022Rémi Verschelde
Happy new year to the wonderful Godot community!
2021-12-15[Net] Fix WebRTC returning packets from peers too early.Fabio Alessandrelli
Due to the async nature of WebRTC implementations, the multiplayer peer could end up having queued packets from a given connection before it is able to emit the "peer_added" signal. This commit ensures that packets from peers which are not notified yet are skipped by `get_packet` and `get_available_packet_count`.
2021-10-01[Net] Rename RPC constants and annotation arguments.Fabio Alessandrelli
any -> any_peer sync -> call_local ordered -> unreliable_ordered Multiplayer.RPC_MODE_ANY -> RPC_MODE_ANY_PEER Multiplayer.TRANSFER_MODE_ORDERED -> TRANSFER_MODE_UNRELIABLE_ORDERED
2021-09-30Use range iterators for `Map`Lightning_A
2021-09-24[Net] MultiplayerPeer cleanup, defaults.Fabio Alessandrelli
2021-09-07[Net] Move multiplayer to core subdir, split RPCManager.Fabio Alessandrelli
Move multiplayer classes to "core/multiplayer" subdir. Move the RPCConfig and enums (TransferMode, RPCMode) to a separate file (multiplayer.h), and bind them to the global namespace. Move the RPC handling code to its own class (RPCManager). Renames "get_rpc_sender_id" to "get_remote_sender_id".
2021-07-30[Net] Implement RPC channels in MultiplayerAPI.Fabio Alessandrelli
2021-07-26Use Ref<T> references as iterators where relevantRémi Verschelde
And const when possible.
2021-07-23Use C++ iterators for Lists in many situationsAaron Franke
2021-07-18Optimize StringName usagereduz
* Added a new macro SNAME() that constructs and caches a local stringname. * Subsequent usages use the cached version. * Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time. * Replaced all theme usages by this new macro. * Replace all signal emission usages by this new macro. * Replace all call_deferred usages by this new macro. This is part of ongoing work to optimize GUI and the editor.
2021-07-12[Net] Rename WebRTCMultiplayer to WebRTCMultiplayerPeer.Fabio Alessandrelli