mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-06 16:00:08 +01:00
The signaling server protocol has been rewritten to use JSON format to be more readable. Lobbies now support both mesh and client/server modes (selected during creation). The client/server mode uses the SceneMultiplayer relay mode as implemented in beta4. The demo now uses an RPC for pinging, and connects to the MultiplayerAPI instead of using the raw MultiplayerPeer.
25 lines
619 B
GDScript
25 lines
619 B
GDScript
extends Control
|
|
|
|
func _enter_tree():
|
|
for c in $VBoxContainer/Clients.get_children():
|
|
# So each child gets its own separate MultiplayerAPI.
|
|
get_tree().set_multiplayer(
|
|
MultiplayerAPI.create_default_interface(),
|
|
NodePath("%s/VBoxContainer/Clients/%s" % [get_path(), c.name])
|
|
)
|
|
|
|
func _ready():
|
|
if OS.get_name() == "HTML5":
|
|
$VBoxContainer/Signaling.hide()
|
|
|
|
|
|
func _on_listen_toggled(button_pressed):
|
|
if button_pressed:
|
|
$Server.listen(int($VBoxContainer/Signaling/Port.value))
|
|
else:
|
|
$Server.stop()
|
|
|
|
|
|
func _on_LinkButton_pressed():
|
|
OS.shell_open("https://github.com/godotengine/webrtc-native/releases")
|