Re-organize to handle disco
This commit is contained in:
parent
f9d8cea66f
commit
d64fd5cb16
|
|
@ -18,10 +18,20 @@ const (
|
|||
|
||||
var (
|
||||
ChanAuthCode = make(chan string)
|
||||
identity = &xmpp.DiscoIdentity{Category: "gateway", Type: "steam", Name: "Steam Gateway"}
|
||||
)
|
||||
|
||||
func execDiscoCommand(iq *xmpp.Iq) {
|
||||
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)
|
||||
discoItem := &xmpp.DiscoItems{Node: xmpp.NodeAdHocCommand}
|
||||
|
||||
|
|
@ -47,6 +57,20 @@ func execDiscoCommand(iq *xmpp.Iq) {
|
|||
reply.PayloadEncode(discoItem)
|
||||
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) {
|
||||
adHoc := &xmpp.AdHocCommand{}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ func mainXMPP() {
|
|||
} else {
|
||||
sendNotSupportedFeature(v)
|
||||
}
|
||||
case xmpp.NSDiscoInfo:
|
||||
execDisco(v)
|
||||
|
||||
case xmpp.NodeAdHocCommand:
|
||||
if jidBare == jid.Domain {
|
||||
|
|
|
|||
Loading…
Reference in New Issue