main.gd 658 B

1234567891011121314151617181920212223242526
  1. extends Control
  2. func _enter_tree() -> void:
  3. for c in $VBoxContainer/Clients.get_children():
  4. # So each child gets its own separate MultiplayerAPI.
  5. get_tree().set_multiplayer(
  6. MultiplayerAPI.create_default_interface(),
  7. NodePath("%s/VBoxContainer/Clients/%s" % [get_path(), c.name])
  8. )
  9. func _ready() -> void:
  10. if OS.get_name() == "Web":
  11. $VBoxContainer/Signaling.hide()
  12. func _on_listen_toggled(button_pressed: bool) -> void:
  13. if button_pressed:
  14. $Server.listen(int($VBoxContainer/Signaling/Port.value))
  15. else:
  16. $Server.stop()
  17. func _on_LinkButton_pressed() -> void:
  18. OS.shell_open("https://github.com/godotengine/webrtc-native/releases")