diff --git a/_examples/go.mod b/_examples/go.mod index a4e46dc..0d499e8 100644 --- a/_examples/go.mod +++ b/_examples/go.mod @@ -6,5 +6,5 @@ require ( github.com/google/go-cmp v0.3.0 // indirect github.com/processone/mpg123 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 ) diff --git a/_examples/go.sum b/_examples/go.sum index b28df9c..8a9b972 100644 --- a/_examples/go.sum +++ b/_examples/go.sum @@ -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= 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-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= diff --git a/_examples/xmpp_component/xmpp_component.go b/_examples/xmpp_component/xmpp_component.go index 7b9174c..0981196 100644 --- a/_examples/xmpp_component/xmpp_component.go +++ b/_examples/xmpp_component/xmpp_component.go @@ -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) +}