mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-21 18:12:00 -08:00
Clean-up
This commit is contained in:
parent
cb2af43fe3
commit
8cb1e1264e
@ -44,6 +44,10 @@ func main() {
|
|||||||
reply := p.MakeError(xError)
|
reply := p.MakeError(xError)
|
||||||
component.xmpp.Send(&reply)
|
component.xmpp.Send(&reply)
|
||||||
}
|
}
|
||||||
|
case xmpp.Message:
|
||||||
|
fmt.Println("Received message:", p.Body)
|
||||||
|
case xmpp.Presence:
|
||||||
|
fmt.Println("Received presence:", p.Type)
|
||||||
default:
|
default:
|
||||||
fmt.Println("ignoring packet:", packet)
|
fmt.Println("ignoring packet:", packet)
|
||||||
}
|
}
|
||||||
|
49
iq.go
49
iq.go
@ -3,63 +3,14 @@ package xmpp // import "fluux.io/xmpp"
|
|||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"fluux.io/xmpp/iot"
|
"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
|
TODO support ability to put Raw payload
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -70,7 +70,7 @@ func next(p *xml.Decoder) (Packet, error) {
|
|||||||
return nil, err
|
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 {
|
switch se.Name.Space {
|
||||||
case NSStream:
|
case NSStream:
|
||||||
return decodeStream(p, se)
|
return decodeStream(p, se)
|
||||||
|
@ -25,5 +25,6 @@ var presence presenceDecoder
|
|||||||
func (presenceDecoder) decode(p *xml.Decoder, se xml.StartElement) (Presence, error) {
|
func (presenceDecoder) decode(p *xml.Decoder, se xml.StartElement) (Presence, error) {
|
||||||
var packet Presence
|
var packet Presence
|
||||||
err := p.DecodeElement(&packet, &se)
|
err := p.DecodeElement(&packet, &se)
|
||||||
|
// TODO Add default presence type (when omitted)
|
||||||
return packet, err
|
return packet, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user