main.gd 617 B

123456789101112131415161718192021222324
  1. extends Control
  2. func _enter_tree():
  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():
  10. if OS.get_name() == "Web":
  11. $VBoxContainer/Signaling.hide()
  12. func _on_listen_toggled(button_pressed):
  13. if button_pressed:
  14. $Server.listen(int($VBoxContainer/Signaling/Port.value))
  15. else:
  16. $Server.stop()
  17. func _on_LinkButton_pressed():
  18. OS.shell_open("https://github.com/godotengine/webrtc-native/releases")