39 lines
1.1 KiB
GDScript
39 lines
1.1 KiB
GDScript
extends Node
|
|
|
|
var _connection
|
|
|
|
onready var n_Connection := get_node("Connections")
|
|
|
|
func _service_discovery():
|
|
var iq := yield() as Xml.XmlElement
|
|
|
|
var feature_promises := Array()
|
|
for item in iq.children[0].children:
|
|
feature_promises.push_back(_connection.promise_iq(
|
|
item.attributes["jid"], "get",
|
|
n_Connection.disco_info_queury,
|
|
n_Connection.yield_as_is()))
|
|
|
|
while not n_Connection.are_promises_done(feature_promises):
|
|
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())
|
|
|
|
func _ready():
|
|
_connection = n_Connection.establish_new_connection("poto.cafe", "veclavtalica", "-")
|
|
if _connection == null:
|
|
push_error("Connection failed")
|
|
return
|
|
|
|
if _connection.push_iq(_connection.domain, "get",
|
|
n_Connection.disco_items_queury,
|
|
_service_discovery()) != OK:
|
|
push_error("Connection failed")
|
|
return
|