36 lines
1.1 KiB
GDScript
36 lines
1.1 KiB
GDScript
extends Node
|
|
|
|
var _connection
|
|
|
|
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",
|
|
"<query xmlns='http://jabber.org/protocol/disco#items'/>",
|
|
_connection.iq_as_is()))
|
|
|
|
while not _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 = $Connections.establish_new_connection("poto.cafe", "veclavtalica", "-")
|
|
if _connection == null:
|
|
push_error("Connection failed")
|
|
return
|
|
|
|
if _connection.push_iq(_connection.domain, "get",
|
|
"<query xmlns='http://jabber.org/protocol/disco#items'/>",
|
|
_service_discovery()) != OK:
|
|
push_error("Connection failed")
|
|
return
|