Re-organize to handle disco
This commit is contained in:
parent
f9d8cea66f
commit
d64fd5cb16
|
|
@ -18,10 +18,20 @@ const (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ChanAuthCode = make(chan string)
|
ChanAuthCode = make(chan string)
|
||||||
|
identity = &xmpp.DiscoIdentity{Category: "gateway", Type: "steam", Name: "Steam Gateway"}
|
||||||
)
|
)
|
||||||
|
|
||||||
func execDiscoCommand(iq *xmpp.Iq) {
|
func execDiscoCommand(iq *xmpp.Iq) {
|
||||||
log.Printf("%sDiscovery item iq received", LogInfo)
|
log.Printf("%sDiscovery item iq received", LogInfo)
|
||||||
|
|
||||||
|
discoInfo := &xmpp.DiscoItems{}
|
||||||
|
iq.PayloadDecode(discoInfo)
|
||||||
|
if discoInfo.Node == "" {
|
||||||
|
// Disco feature
|
||||||
|
execDisco(iq)
|
||||||
|
return
|
||||||
|
} else if discoInfo.Node == xmpp.NodeAdHocCommand {
|
||||||
|
// Disco Ad-Hoc
|
||||||
reply := iq.Response(xmpp.IQTypeResult)
|
reply := iq.Response(xmpp.IQTypeResult)
|
||||||
discoItem := &xmpp.DiscoItems{Node: xmpp.NodeAdHocCommand}
|
discoItem := &xmpp.DiscoItems{Node: xmpp.NodeAdHocCommand}
|
||||||
|
|
||||||
|
|
@ -46,6 +56,20 @@ func execDiscoCommand(iq *xmpp.Iq) {
|
||||||
|
|
||||||
reply.PayloadEncode(discoItem)
|
reply.PayloadEncode(discoItem)
|
||||||
comp.Out <- reply
|
comp.Out <- reply
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func execDisco(iq *xmpp.Iq) {
|
||||||
|
log.Printf("%sDisco Feature", LogInfo)
|
||||||
|
reply := iq.Response(xmpp.IQTypeResult)
|
||||||
|
|
||||||
|
discoInfo := &xmpp.DiscoInfo{}
|
||||||
|
discoInfo.Identity = append(discoInfo.Identity, *identity)
|
||||||
|
discoInfo.Feature = append(discoInfo.Feature, xmpp.DiscoFeature{Var: xmpp.NSJabberClient})
|
||||||
|
discoInfo.Feature = append(discoInfo.Feature, xmpp.DiscoFeature{Var: xmpp.NodeAdHocCommand})
|
||||||
|
|
||||||
|
reply.PayloadEncode(discoInfo)
|
||||||
|
comp.Out <- reply
|
||||||
}
|
}
|
||||||
|
|
||||||
func execCommandAdHoc(iq *xmpp.Iq) {
|
func execCommandAdHoc(iq *xmpp.Iq) {
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,8 @@ func mainXMPP() {
|
||||||
} else {
|
} else {
|
||||||
sendNotSupportedFeature(v)
|
sendNotSupportedFeature(v)
|
||||||
}
|
}
|
||||||
|
case xmpp.NSDiscoInfo:
|
||||||
|
execDisco(v)
|
||||||
|
|
||||||
case xmpp.NodeAdHocCommand:
|
case xmpp.NodeAdHocCommand:
|
||||||
if jidBare == jid.Domain {
|
if jidBare == jid.Domain {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue