2023-08-26 15:16:36 +00:00
|
|
|
extends Node
|
|
|
|
|
2023-08-26 17:59:43 +00:00
|
|
|
var _connection
|
|
|
|
|
2023-08-27 06:46:51 +00:00
|
|
|
onready var n_Connection := get_node("Connections")
|
|
|
|
|
2023-08-26 17:59:43 +00:00
|
|
|
func _service_discovery():
|
|
|
|
var iq := yield() as Xml.XmlElement
|
2023-08-26 20:52:21 +00:00
|
|
|
|
|
|
|
var feature_promises := Array()
|
|
|
|
for item in iq.children[0].children:
|
2023-08-27 06:46:51 +00:00
|
|
|
feature_promises.push_back(_connection.promise_iq(
|
|
|
|
item.attributes["jid"], "get",
|
|
|
|
n_Connection.disco_info_queury,
|
|
|
|
n_Connection.yield_as_is()))
|
2023-08-26 20:52:21 +00:00
|
|
|
|
2023-08-27 06:46:51 +00:00
|
|
|
while not n_Connection.are_promises_done(feature_promises):
|
2023-08-26 20:52:21 +00:00
|
|
|
yield()
|
|
|
|
|
|
|
|
for feature_promise in feature_promises:
|
|
|
|
if not feature_promise.is_ok:
|
|
|
|
push_error("Connection failed")
|
|
|
|
return
|
|
|
|
|
|
|
|
var feature := feature_promise.value as Xml.XmlElement
|
|
|
|
print(feature.as_string())
|
2023-08-26 17:59:43 +00:00
|
|
|
|
2023-08-26 15:16:36 +00:00
|
|
|
func _ready():
|
2023-08-27 06:46:51 +00:00
|
|
|
_connection = n_Connection.establish_new_connection("poto.cafe", "veclavtalica", "-")
|
2023-08-26 17:59:43 +00:00
|
|
|
if _connection == null:
|
|
|
|
push_error("Connection failed")
|
2023-08-26 20:52:21 +00:00
|
|
|
return
|
2023-08-26 17:59:43 +00:00
|
|
|
|
|
|
|
if _connection.push_iq(_connection.domain, "get",
|
2023-08-27 06:46:51 +00:00
|
|
|
n_Connection.disco_items_queury,
|
2023-08-26 17:59:43 +00:00
|
|
|
_service_discovery()) != OK:
|
2023-08-26 15:16:36 +00:00
|
|
|
push_error("Connection failed")
|
2023-08-26 20:52:21 +00:00
|
|
|
return
|