276 lines
8.2 KiB
Plaintext
276 lines
8.2 KiB
Plaintext
[gd_scene load_steps=8 format=3 uid="uid://sca5nhn6lprk"]
|
|
|
|
[ext_resource type="Script" path="res://mqttexample.gd" id="1_6i2w6"]
|
|
[ext_resource type="PackedScene" uid="uid://ktm7k0co2o7l" path="res://addons/mqtt/mqtt.tscn" id="2_t6rxa"]
|
|
|
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_iasn2"]
|
|
content_margin_left = 5.0
|
|
content_margin_right = 5.0
|
|
bg_color = Color(0.215686, 0.4, 0.4, 1)
|
|
|
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ppk4t"]
|
|
content_margin_left = 5.0
|
|
content_margin_right = 5.0
|
|
bg_color = Color(0.341176, 0.101961, 0.0392157, 1)
|
|
|
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8b54y"]
|
|
content_margin_left = 5.0
|
|
content_margin_right = 5.0
|
|
bg_color = Color(0.341176, 0.101961, 0.0392157, 1)
|
|
|
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_xasl1"]
|
|
content_margin_left = 5.0
|
|
content_margin_right = 5.0
|
|
bg_color = Color(0.341176, 0.101961, 0.0392157, 1)
|
|
|
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_njfq6"]
|
|
bg_color = Color(0.0156863, 0.133333, 0.0431373, 1)
|
|
|
|
[node name="mqttexample" type="Control"]
|
|
layout_mode = 3
|
|
anchors_preset = 15
|
|
anchor_right = 1.0
|
|
anchor_bottom = 1.0
|
|
offset_left = -123.0
|
|
offset_top = -64.0
|
|
offset_right = -1023.0
|
|
offset_bottom = -584.0
|
|
grow_horizontal = 2
|
|
grow_vertical = 2
|
|
script = ExtResource("1_6i2w6")
|
|
|
|
[node name="MQTT" parent="." instance=ExtResource("2_t6rxa")]
|
|
|
|
[node name="VBox" type="VBoxContainer" parent="."]
|
|
self_modulate = Color(0.0588235, 1, 1, 1)
|
|
layout_mode = 0
|
|
offset_left = 137.0
|
|
offset_top = 82.0
|
|
offset_right = 1017.0
|
|
offset_bottom = 576.0
|
|
|
|
[node name="HBoxBrokerControl" type="HBoxContainer" parent="VBox"]
|
|
layout_mode = 2
|
|
|
|
[node name="Labelbroker" type="Label" parent="VBox/HBoxBrokerControl"]
|
|
layout_mode = 2
|
|
theme_type_variation = &"HeaderLarge"
|
|
text = "MQTT broker:"
|
|
|
|
[node name="ButtonConnect" type="CheckButton" parent="VBox/HBoxBrokerControl"]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 6
|
|
text = "Connect to broker"
|
|
|
|
[node name="status" type="Label" parent="VBox/HBoxBrokerControl"]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 2
|
|
theme_override_styles/normal = SubResource("StyleBoxFlat_iasn2")
|
|
text = "...Status"
|
|
horizontal_alignment = 1
|
|
|
|
[node name="HBoxBroker" type="HBoxContainer" parent="VBox"]
|
|
layout_mode = 2
|
|
|
|
[node name="Label" type="Label" parent="VBox/HBoxBroker"]
|
|
layout_mode = 2
|
|
text = "URL: "
|
|
|
|
[node name="brokeraddress" type="LineEdit" parent="VBox/HBoxBroker"]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 3
|
|
text = "broker.hivemq.com"
|
|
|
|
[node name="Label4" type="Label" parent="VBox/HBoxBroker"]
|
|
layout_mode = 2
|
|
text = "User:"
|
|
|
|
[node name="brokeruser" type="LineEdit" parent="VBox/HBoxBroker"]
|
|
layout_mode = 2
|
|
|
|
[node name="Label5" type="Label" parent="VBox/HBoxBroker"]
|
|
layout_mode = 2
|
|
text = "Pswd:"
|
|
|
|
[node name="brokerpswd" type="LineEdit" parent="VBox/HBoxBroker"]
|
|
layout_mode = 2
|
|
|
|
[node name="Label2" type="Label" parent="VBox/HBoxBroker"]
|
|
layout_mode = 2
|
|
text = "Port: "
|
|
|
|
[node name="brokerport" type="LineEdit" parent="VBox/HBoxBroker"]
|
|
layout_mode = 2
|
|
tooltip_text = "Port
|
|
"
|
|
text = "1883"
|
|
|
|
[node name="Label3" type="Label" parent="VBox/HBoxBroker"]
|
|
layout_mode = 2
|
|
text = "Protocol: "
|
|
|
|
[node name="brokerprotocol" type="OptionButton" parent="VBox/HBoxBroker"]
|
|
layout_mode = 2
|
|
item_count = 4
|
|
selected = 0
|
|
popup/item_0/text = "tcp://"
|
|
popup/item_0/id = 0
|
|
popup/item_1/text = "ssl://"
|
|
popup/item_1/id = 1
|
|
popup/item_2/text = "ws://"
|
|
popup/item_2/id = 2
|
|
popup/item_3/text = "wss://"
|
|
popup/item_3/id = 3
|
|
|
|
[node name="HSeparator" type="HSeparator" parent="VBox"]
|
|
custom_minimum_size = Vector2(0, 10)
|
|
layout_mode = 2
|
|
|
|
[node name="HBoxLastwill" type="HBoxContainer" parent="VBox"]
|
|
layout_mode = 2
|
|
|
|
[node name="Labellastwill" type="Label" parent="VBox/HBoxLastwill"]
|
|
layout_mode = 2
|
|
theme_type_variation = &"HeaderMedium"
|
|
text = "Last will:"
|
|
|
|
[node name="Label" type="Label" parent="VBox/HBoxLastwill"]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 10
|
|
text = "topic:"
|
|
|
|
[node name="lastwilltopic" type="LineEdit" parent="VBox/HBoxLastwill"]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 3
|
|
text = "godot/myname/mywill"
|
|
|
|
[node name="Label2" type="Label" parent="VBox/HBoxLastwill"]
|
|
layout_mode = 2
|
|
text = "message:"
|
|
|
|
[node name="lastwillmessage" type="LineEdit" parent="VBox/HBoxLastwill"]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 3
|
|
text = "goodbye world"
|
|
|
|
[node name="lastwillretain" type="CheckButton" parent="VBox/HBoxLastwill"]
|
|
layout_mode = 2
|
|
text = "Retain
|
|
"
|
|
|
|
[node name="HSeparator2" type="HSeparator" parent="VBox"]
|
|
custom_minimum_size = Vector2(0, 10)
|
|
layout_mode = 2
|
|
|
|
[node name="HBoxSubscriptions" type="HBoxContainer" parent="VBox"]
|
|
layout_mode = 2
|
|
|
|
[node name="Labellastwill2" type="Label" parent="VBox/HBoxSubscriptions"]
|
|
layout_mode = 2
|
|
theme_type_variation = &"HeaderMedium"
|
|
text = "Subscriptions:"
|
|
|
|
[node name="Label3" type="Label" parent="VBox/HBoxSubscriptions"]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 10
|
|
text = "topic:"
|
|
|
|
[node name="subscribetopic" type="LineEdit" parent="VBox/HBoxSubscriptions"]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 3
|
|
text = "godot/+"
|
|
|
|
[node name="subscribe" type="Button" parent="VBox/HBoxSubscriptions"]
|
|
layout_mode = 2
|
|
theme_override_styles/normal = SubResource("StyleBoxFlat_ppk4t")
|
|
text = "subscribe
|
|
"
|
|
|
|
[node name="subscriptions" type="OptionButton" parent="VBox/HBoxSubscriptions"]
|
|
custom_minimum_size = Vector2(100, 0)
|
|
layout_mode = 2
|
|
size_flags_horizontal = 10
|
|
tooltip_text = "Subscribed topics
|
|
"
|
|
item_count = 1
|
|
selected = 0
|
|
popup/item_0/text = "<none>"
|
|
popup/item_0/id = 0
|
|
|
|
[node name="unsubscribe" type="Button" parent="VBox/HBoxSubscriptions"]
|
|
layout_mode = 2
|
|
theme_override_constants/outline_size = 0
|
|
theme_override_styles/normal = SubResource("StyleBoxFlat_8b54y")
|
|
text = "unsubscribe
|
|
"
|
|
|
|
[node name="HSeparator3" type="HSeparator" parent="VBox"]
|
|
custom_minimum_size = Vector2(0, 10)
|
|
layout_mode = 2
|
|
|
|
[node name="HBoxPublish" type="HBoxContainer" parent="VBox"]
|
|
layout_mode = 2
|
|
|
|
[node name="Labellastwill" type="Label" parent="VBox/HBoxPublish"]
|
|
layout_mode = 2
|
|
theme_type_variation = &"HeaderMedium"
|
|
text = "Publish:"
|
|
|
|
[node name="Label" type="Label" parent="VBox/HBoxPublish"]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 10
|
|
text = "topic:"
|
|
|
|
[node name="publishtopic" type="LineEdit" parent="VBox/HBoxPublish"]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 3
|
|
text = "godot/myname"
|
|
|
|
[node name="Label2" type="Label" parent="VBox/HBoxPublish"]
|
|
layout_mode = 2
|
|
text = "message:"
|
|
|
|
[node name="publishmessage" type="LineEdit" parent="VBox/HBoxPublish"]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 3
|
|
text = "hello there"
|
|
|
|
[node name="publishretain" type="CheckButton" parent="VBox/HBoxPublish"]
|
|
layout_mode = 2
|
|
text = "Retain
|
|
"
|
|
|
|
[node name="publish" type="Button" parent="VBox/HBoxPublish"]
|
|
layout_mode = 2
|
|
theme_override_styles/normal = SubResource("StyleBoxFlat_xasl1")
|
|
text = "Publish"
|
|
|
|
[node name="HSeparator4" type="HSeparator" parent="VBox"]
|
|
custom_minimum_size = Vector2(0, 10)
|
|
layout_mode = 2
|
|
|
|
[node name="subscribedmessages" type="RichTextLabel" parent="VBox"]
|
|
layout_mode = 2
|
|
size_flags_vertical = 3
|
|
theme_override_styles/normal = SubResource("StyleBoxFlat_njfq6")
|
|
bbcode_enabled = true
|
|
text = "[b]Instructions[/b]
|
|
|
|
MQTT is a lightweight easy-to-use publish and subscribe (\"pubsub\") networking protocol.
|
|
|
|
By default this app connects to the public server hosted at [u]https://test.mosquitto.org/[/u] , but you can connect to another broker or your own instance.
|
|
|
|
[i]Commands to run on another computer terminal:[/i]
|
|
> mosquitto_pub -h test.mosquitto.org -t \"godot/abcd\" -m \"Bingo!\"
|
|
> mosquitto_sub -v -h test.mosquitto.org -t \"godot/#\""
|
|
|
|
[connection signal="broker_connected" from="MQTT" to="." method="_on_mqtt_broker_connected"]
|
|
[connection signal="broker_connection_failed" from="MQTT" to="." method="_on_mqtt_broker_connection_failed"]
|
|
[connection signal="broker_disconnected" from="MQTT" to="." method="_on_mqtt_broker_disconnected"]
|
|
[connection signal="received_message" from="MQTT" to="." method="_on_mqtt_received_message"]
|
|
[connection signal="toggled" from="VBox/HBoxBrokerControl/ButtonConnect" to="." method="_on_button_connect_toggled"]
|
|
[connection signal="item_selected" from="VBox/HBoxBroker/brokerprotocol" to="." method="_on_brokerprotocol_item_selected"]
|
|
[connection signal="pressed" from="VBox/HBoxSubscriptions/subscribe" to="." method="_on_subscribe_pressed"]
|
|
[connection signal="pressed" from="VBox/HBoxSubscriptions/unsubscribe" to="." method="_on_unsubscribe_pressed"]
|
|
[connection signal="pressed" from="VBox/HBoxPublish/publish" to="." method="_on_publish_pressed"]
|