Update component to advertise version feature and return it

This commit is contained in:
Mickael Remond
2019-06-10 12:35:48 +02:00
parent 322a6594e7
commit 08bb9965b8
3 changed files with 21 additions and 1 deletions

View File

@@ -44,6 +44,11 @@ func main() {
if p.Type == "get" {
discoItems(component, p.PacketAttrs, inner)
}
case *xmpp.Version:
fmt.Println("Version")
if p.Type == "get" {
version(component, p.PacketAttrs)
}
default:
fmt.Println("ignoring iq packet", inner)
xError := xmpp.Err{
@@ -83,6 +88,7 @@ func discoResult(c *xmpp.Component, attrs xmpp.PacketAttrs, info *xmpp.DiscoInfo
Features: []xmpp.Feature{
{Var: xmpp.NSDiscoInfo},
{Var: xmpp.NSDiscoItems},
{Var: "jabber:iq:version"},
},
}
iq.AddPayload(&payload)
@@ -104,3 +110,13 @@ func discoItems(c *xmpp.Component, attrs xmpp.PacketAttrs, items *xmpp.DiscoItem
iq.AddPayload(&payload)
_ = c.Send(iq)
}
func version(c *xmpp.Component, attrs xmpp.PacketAttrs) {
iq := xmpp.NewIQ("result", attrs.To, attrs.From, attrs.Id, "en")
var payload xmpp.Version
payload.Name = "Fluux XMPP Component"
payload.Version = "0.0.1"
iq.AddPayload(&payload)
_ = c.Send(iq)
}