mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-21 10:02:00 -08:00
Clean-up
This commit is contained in:
parent
cb2af43fe3
commit
8cb1e1264e
@ -44,6 +44,10 @@ func main() {
|
||||
reply := p.MakeError(xError)
|
||||
component.xmpp.Send(&reply)
|
||||
}
|
||||
case xmpp.Message:
|
||||
fmt.Println("Received message:", p.Body)
|
||||
case xmpp.Presence:
|
||||
fmt.Println("Received presence:", p.Type)
|
||||
default:
|
||||
fmt.Println("ignoring packet:", packet)
|
||||
}
|
||||
|
49
iq.go
49
iq.go
@ -3,63 +3,14 @@ package xmpp // import "fluux.io/xmpp"
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
|
||||
"reflect"
|
||||
|
||||
"strconv"
|
||||
|
||||
"fluux.io/xmpp/iot"
|
||||
)
|
||||
|
||||
/*
|
||||
TODO I would like to be able to write
|
||||
|
||||
NewIQ(Id, From, To, Type, Lang).AddPayload(IQPayload)
|
||||
Payload would be:
|
||||
|
||||
payload := Node{
|
||||
Ns: "http://jabber.org/protocol/disco#info",
|
||||
Tag: "identity",
|
||||
Attrs: map[string]string{
|
||||
"category":"gateway",
|
||||
"type": "skype",
|
||||
"name": "Test Gateway",
|
||||
},
|
||||
Nodes: []Node{},
|
||||
}
|
||||
|
||||
AddPayload(Ns, Tag, Attrs)
|
||||
|
||||
ex:
|
||||
|
||||
NewIQ("get", "test@localhost", "admin@localhost", "en")
|
||||
.AddPayload("http://jabber.org/protocol/disco#info",
|
||||
"identity",
|
||||
map[string]string{
|
||||
"category":"gateway",
|
||||
"type": "skype",
|
||||
"name": "Test Gateway",
|
||||
})
|
||||
|
||||
NewNode(Ns, Tag, Attrs)
|
||||
NewNodeWithChildren(Ns, Tag, Attrs, Nodes)
|
||||
|
||||
Attr {
|
||||
K string
|
||||
V string
|
||||
}
|
||||
|
||||
xmpp.Elt.DiscoInfo("identity", "gateway", "skype", "Test Gateway")
|
||||
xmppElt.DiscoInfo.identity("
|
||||
import xmpp/node/discoinfo
|
||||
|
||||
discoinfo.Identity("gateway", "skype", "Test Gateway")
|
||||
|
||||
|
||||
[]Attr{{"category", "gateway"}
|
||||
|
||||
TODO support ability to put Raw payload
|
||||
|
||||
*/
|
||||
|
||||
// ============================================================================
|
||||
|
@ -70,7 +70,7 @@ func next(p *xml.Decoder) (Packet, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: general case = Parse IQ / presence / message => split SASL Stream and component cases
|
||||
// Decode one of the top level XMPP namespace
|
||||
switch se.Name.Space {
|
||||
case NSStream:
|
||||
return decodeStream(p, se)
|
||||
|
@ -25,5 +25,6 @@ var presence presenceDecoder
|
||||
func (presenceDecoder) decode(p *xml.Decoder, se xml.StartElement) (Presence, error) {
|
||||
var packet Presence
|
||||
err := p.DecodeElement(&packet, &se)
|
||||
// TODO Add default presence type (when omitted)
|
||||
return packet, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user