From 93509019a9a22b6223cf425d5cc9a0609cc7be2e Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Mon, 14 Nov 2022 22:53:21 +0100 Subject: [PATCH] Update WebRTC minimal to 4.0-beta4. --- networking/webrtc_minimal/chat.gd | 6 ++--- networking/webrtc_minimal/main.tscn | 32 ++++++++++++------------- networking/webrtc_minimal/minimal.gd | 16 ++++++------- networking/webrtc_minimal/project.godot | 4 ++-- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/networking/webrtc_minimal/chat.gd b/networking/webrtc_minimal/chat.gd index 87ab7326..032f8dae 100644 --- a/networking/webrtc_minimal/chat.gd +++ b/networking/webrtc_minimal/chat.gd @@ -8,8 +8,8 @@ var channel = peer.create_data_channel("chat", {"negotiated": true, "id": 1}) func _ready(): # Connect all functions. - peer.connect(&"ice_candidate_created", self._on_ice_candidate) - peer.connect(&"session_description_created", self._on_session) + peer.ice_candidate_created.connect(_on_ice_candidate) + peer.session_description_created.connect(_on_session) # Register to the local signaling server (see below for the implementation). Signaling.register(String(get_path())) @@ -36,4 +36,4 @@ func _process(delta): func send_message(message): - channel.put_packet(message.to_utf8()) + channel.put_packet(message.to_utf8_buffer()) diff --git a/networking/webrtc_minimal/main.tscn b/networking/webrtc_minimal/main.tscn index c5046eb7..215d132c 100644 --- a/networking/webrtc_minimal/main.tscn +++ b/networking/webrtc_minimal/main.tscn @@ -1,30 +1,28 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=4 format=3 uid="uid://bvmm5mgb38ysa"] -[ext_resource path="res://minimal.tscn" type="PackedScene" id=1] -[ext_resource path="res://main.gd" type="Script" id=2] -[ext_resource path="res://link_button.gd" type="Script" id=3] +[ext_resource type="PackedScene" path="res://minimal.tscn" id="1"] +[ext_resource type="Script" path="res://main.gd" id="2"] +[ext_resource type="Script" path="res://link_button.gd" id="3"] [node name="Main" type="Node"] -script = ExtResource( 2 ) +script = ExtResource("2") -[node name="Minimal" parent="." instance=ExtResource( 1 )] +[node name="Minimal" parent="." instance=ExtResource("1")] [node name="CenterContainer" type="CenterContainer" parent="."] +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -__meta__ = { -"_edit_use_anchors_": true -} +grow_horizontal = 2 +grow_vertical = 2 [node name="LinkButton" type="LinkButton" parent="CenterContainer"] -offset_left = 239.0 -offset_top = 293.0 -offset_right = 785.0 -offset_bottom = 307.0 +layout_mode = 2 +offset_left = 245.0 +offset_top = 312.0 +offset_right = 906.0 +offset_bottom = 335.0 text = "Make sure to download the GDNative WebRTC Plugin and place it in the project folder" -script = ExtResource( 3 ) -__meta__ = { -"_edit_use_anchors_": false -} +script = ExtResource("3") [connection signal="pressed" from="CenterContainer/LinkButton" to="CenterContainer/LinkButton" method="_on_LinkButton_pressed"] diff --git a/networking/webrtc_minimal/minimal.gd b/networking/webrtc_minimal/minimal.gd index 4dd5cf34..5311ad83 100644 --- a/networking/webrtc_minimal/minimal.gd +++ b/networking/webrtc_minimal/minimal.gd @@ -10,26 +10,26 @@ var ch2 = p2.create_data_channel("chat", {"id": 1, "negotiated": true}) func _ready(): print(p1.create_data_channel("chat", {"id": 1, "negotiated": true})) # Connect P1 session created to itself to set local description. - p1.connect(&"session_description_created", p1.set_local_description) + p1.session_description_created.connect(p1.set_local_description) # Connect P1 session and ICE created to p2 set remote description and candidates. - p1.connect(&"session_description_created", p2.set_remote_description) - p1.connect(&"ice_candidate_created", p2.add_ice_candidate) + p1.session_description_created.connect(p2.set_remote_description) + p1.ice_candidate_created.connect(p2.add_ice_candidate) # Same for P2. - p2.connect(&"session_description_created", p2.set_local_description) - p2.connect(&"session_description_created", p1.set_remote_description) - p2.connect(&"ice_candidate_created", p1.add_ice_candidate) + p2.session_description_created.connect(p2.set_local_description) + p2.session_description_created.connect(p1.set_remote_description) + p2.ice_candidate_created.connect(p1.add_ice_candidate) # Let P1 create the offer. p1.create_offer() # Wait a second and send message from P1. await get_tree().create_timer(1).timeout - ch1.put_packet("Hi from P1".to_utf8()) + ch1.put_packet("Hi from P1".to_utf8_buffer()) # Wait a second and send message from P2. await get_tree().create_timer(1).timeout - ch2.put_packet("Hi from P2".to_utf8()) + ch2.put_packet("Hi from P2".to_utf8_buffer()) func _process(delta): diff --git a/networking/webrtc_minimal/project.godot b/networking/webrtc_minimal/project.godot index 30613b65..e48ebed3 100644 --- a/networking/webrtc_minimal/project.godot +++ b/networking/webrtc_minimal/project.godot @@ -6,13 +6,14 @@ ; [section] ; section goes between [] ; param=value ; assign values to parameters -config_version=4 +config_version=5 [application] config/name="WebRTC Minimal Connection" config/description="This is a minimal sample of using WebRTC connections to connect two peers to each other." run/main_scene="res://main.tscn" +config/features=PackedStringArray("4.0") [autoload] @@ -20,7 +21,6 @@ Signaling="*res://Signaling.gd" [display] -window/dpi/allow_hidpi=true window/stretch/mode="2d" window/stretch/aspect="expand"