mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
[MP] Let MultiplayerAPI handle packet relaying and peer signaling.
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.
This commit is contained in:
@@ -78,6 +78,10 @@ bool MultiplayerPeer::is_refusing_new_connections() const {
|
||||
return refuse_connections;
|
||||
}
|
||||
|
||||
bool MultiplayerPeer::is_server_relay_supported() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void MultiplayerPeer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_transfer_channel", "channel"), &MultiplayerPeer::set_transfer_channel);
|
||||
ClassDB::bind_method(D_METHOD("get_transfer_channel"), &MultiplayerPeer::get_transfer_channel);
|
||||
@@ -86,6 +90,8 @@ void MultiplayerPeer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_target_peer", "id"), &MultiplayerPeer::set_target_peer);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_packet_peer"), &MultiplayerPeer::get_packet_peer);
|
||||
ClassDB::bind_method(D_METHOD("get_packet_channel"), &MultiplayerPeer::get_packet_channel);
|
||||
ClassDB::bind_method(D_METHOD("get_packet_mode"), &MultiplayerPeer::get_packet_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("poll"), &MultiplayerPeer::poll);
|
||||
|
||||
@@ -96,6 +102,8 @@ void MultiplayerPeer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_refuse_new_connections", "enable"), &MultiplayerPeer::set_refuse_new_connections);
|
||||
ClassDB::bind_method(D_METHOD("is_refusing_new_connections"), &MultiplayerPeer::is_refusing_new_connections);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_server_relay_supported"), &MultiplayerPeer::is_server_relay_supported);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_connections"), "set_refuse_new_connections", "is_refusing_new_connections");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "transfer_mode", PROPERTY_HINT_ENUM, "Unreliable,Unreliable Ordered,Reliable"), "set_transfer_mode", "get_transfer_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "transfer_channel", PROPERTY_HINT_RANGE, "0,255,1"), "set_transfer_channel", "get_transfer_channel");
|
||||
@@ -177,6 +185,14 @@ bool MultiplayerPeerExtension::is_refusing_new_connections() const {
|
||||
return MultiplayerPeer::is_refusing_new_connections();
|
||||
}
|
||||
|
||||
bool MultiplayerPeerExtension::is_server_relay_supported() const {
|
||||
bool can_relay;
|
||||
if (GDVIRTUAL_CALL(_is_server_relay_supported, can_relay)) {
|
||||
return can_relay;
|
||||
}
|
||||
return MultiplayerPeer::is_server_relay_supported();
|
||||
}
|
||||
|
||||
void MultiplayerPeerExtension::_bind_methods() {
|
||||
GDVIRTUAL_BIND(_get_packet, "r_buffer", "r_buffer_size");
|
||||
GDVIRTUAL_BIND(_put_packet, "p_buffer", "p_buffer_size");
|
||||
|
||||
Reference in New Issue
Block a user