mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-16 13:30:07 +01:00
Update WebRTC minimal to 4.0-beta4.
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user