diff --git a/cmd/xmpp_component/xmpp_component.go b/cmd/xmpp_component/xmpp_component.go index a2f75ba..12f3997 100644 --- a/cmd/xmpp_component/xmpp_component.go +++ b/cmd/xmpp_component/xmpp_component.go @@ -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) } diff --git a/iq.go b/iq.go index c2063f0..be1e057 100644 --- a/iq.go +++ b/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 - */ // ============================================================================ diff --git a/parser.go b/parser.go index 533f8a2..1142976 100644 --- a/parser.go +++ b/parser.go @@ -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) diff --git a/presence.go b/presence.go index 6d9eaed..d079f49 100644 --- a/presence.go +++ b/presence.go @@ -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 }