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
No known key found for this signature in database
GPG key ID: E6F6045D79965AA3
3 changed files with 21 additions and 1 deletions

View file

@ -6,5 +6,5 @@ require (
github.com/google/go-cmp v0.3.0 // indirect github.com/google/go-cmp v0.3.0 // indirect
github.com/processone/mpg123 v1.0.0 github.com/processone/mpg123 v1.0.0
github.com/processone/soundcloud v1.0.0 github.com/processone/soundcloud v1.0.0
gosrc.io/xmpp v0.0.0-20190609110825-bc2fad6693da gosrc.io/xmpp v0.0.0-20190610103001-322a6594e7f9
) )

View file

@ -7,3 +7,7 @@ golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522 h1:bhOzK9QyoD0ogCnFro1m2
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gosrc.io/xmpp v0.0.0-20190609110825-bc2fad6693da h1:LmOtwrmeUIWTG87zgPc99ouMPDowrRtgEsCKKvkmanQ= gosrc.io/xmpp v0.0.0-20190609110825-bc2fad6693da h1:LmOtwrmeUIWTG87zgPc99ouMPDowrRtgEsCKKvkmanQ=
gosrc.io/xmpp v0.0.0-20190609110825-bc2fad6693da/go.mod h1:6NJG4vRCxQJMGLxIdroPLPd++FPLOmDqJdJEt2mu4kQ= gosrc.io/xmpp v0.0.0-20190609110825-bc2fad6693da/go.mod h1:6NJG4vRCxQJMGLxIdroPLPd++FPLOmDqJdJEt2mu4kQ=
gosrc.io/xmpp v0.0.0-20190610095607-45cb2e6f343a h1:CUG1rGnMuMYUX2y9N/uPaDe/CS27GdNnxhnSmBAjCic=
gosrc.io/xmpp v0.0.0-20190610095607-45cb2e6f343a/go.mod h1:6NJG4vRCxQJMGLxIdroPLPd++FPLOmDqJdJEt2mu4kQ=
gosrc.io/xmpp v0.0.0-20190610103001-322a6594e7f9 h1:CJpDd5q0iH08ntle+uO5XNx+EGUycafYYR175pyPqOQ=
gosrc.io/xmpp v0.0.0-20190610103001-322a6594e7f9/go.mod h1:6NJG4vRCxQJMGLxIdroPLPd++FPLOmDqJdJEt2mu4kQ=

View file

@ -44,6 +44,11 @@ func main() {
if p.Type == "get" { if p.Type == "get" {
discoItems(component, p.PacketAttrs, inner) discoItems(component, p.PacketAttrs, inner)
} }
case *xmpp.Version:
fmt.Println("Version")
if p.Type == "get" {
version(component, p.PacketAttrs)
}
default: default:
fmt.Println("ignoring iq packet", inner) fmt.Println("ignoring iq packet", inner)
xError := xmpp.Err{ xError := xmpp.Err{
@ -83,6 +88,7 @@ func discoResult(c *xmpp.Component, attrs xmpp.PacketAttrs, info *xmpp.DiscoInfo
Features: []xmpp.Feature{ Features: []xmpp.Feature{
{Var: xmpp.NSDiscoInfo}, {Var: xmpp.NSDiscoInfo},
{Var: xmpp.NSDiscoItems}, {Var: xmpp.NSDiscoItems},
{Var: "jabber:iq:version"},
}, },
} }
iq.AddPayload(&payload) iq.AddPayload(&payload)
@ -104,3 +110,13 @@ func discoItems(c *xmpp.Component, attrs xmpp.PacketAttrs, items *xmpp.DiscoItem
iq.AddPayload(&payload) iq.AddPayload(&payload)
_ = c.Send(iq) _ = 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)
}