forked from chteufleur/go-xmpp
Collect and consolidate namespaces.
This commit is contained in:
parent
f9302660b0
commit
82015bcab4
|
|
@ -85,8 +85,8 @@ func startClient(stream *Stream, jid JID) error {
|
|||
start := xml.StartElement{
|
||||
xml.Name{"stream", "stream"},
|
||||
[]xml.Attr{
|
||||
xml.Attr{xml.Name{"", "xmlns"}, "jabber:client"},
|
||||
xml.Attr{xml.Name{"xmlns", "stream"}, "http://etherx.jabber.org/streams"},
|
||||
xml.Attr{xml.Name{"", "xmlns"}, nsClient},
|
||||
xml.Attr{xml.Name{"xmlns", "stream"}, nsStreams},
|
||||
xml.Attr{xml.Name{"", "from"}, jid.Full()},
|
||||
xml.Attr{xml.Name{"", "to"}, jid.Domain},
|
||||
xml.Attr{xml.Name{"", "version"}, "1.0"},
|
||||
|
|
@ -96,7 +96,7 @@ func startClient(stream *Stream, jid JID) error {
|
|||
if rstart, err := stream.SendStart(&start); err != nil {
|
||||
return err
|
||||
} else {
|
||||
if rstart.Name != (xml.Name{nsStream, "stream"}) {
|
||||
if rstart.Name != (xml.Name{nsStreams, "stream"}) {
|
||||
return fmt.Errorf("unexpected start element: %s", rstart.Name)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ func startComponent(stream *Stream, jid JID) (string, error) {
|
|||
start := xml.StartElement{
|
||||
xml.Name{"stream", "stream"},
|
||||
[]xml.Attr{
|
||||
xml.Attr{xml.Name{"", "xmlns"}, "jabber:component:accept"},
|
||||
xml.Attr{xml.Name{"xmlns", "stream"}, "http://etherx.jabber.org/streams"},
|
||||
xml.Attr{xml.Name{"", "xmlns"}, nsComponentAccept},
|
||||
xml.Attr{xml.Name{"xmlns", "stream"}, nsStreams},
|
||||
xml.Attr{xml.Name{"", "to"}, jid.Full()},
|
||||
},
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ func startComponent(stream *Stream, jid JID) (string, error) {
|
|||
if rstart, err := stream.SendStart(&start); err != nil {
|
||||
return "", err
|
||||
} else {
|
||||
if rstart.Name != (xml.Name{nsStream, "stream"}) {
|
||||
if rstart.Name != (xml.Name{nsStreams, "stream"}) {
|
||||
return "", fmt.Errorf("unexpected start element: %s", rstart.Name)
|
||||
}
|
||||
// Find the stream id.
|
||||
|
|
@ -73,7 +73,7 @@ func handshake(stream *Stream, streamId, secret string) error {
|
|||
if start, err := stream.Next(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
if start.Name != (xml.Name{"jabber:component:accept", "handshake"}) {
|
||||
if start.Name != (xml.Name{nsComponentAccept, "handshake"}) {
|
||||
return fmt.Errorf("Expected <handshake/>, for %s", start.Name)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
package xmpp
|
||||
|
||||
const (
|
||||
nsStreams = "http://etherx.jabber.org/streams"
|
||||
nsClient = "jabber:client"
|
||||
nsTLS = "urn:ietf:params:xml:ns:xmpp-tls"
|
||||
nsComponentAccept = "jabber:component:accept"
|
||||
nsErrorStanzas = "urn:ietf:params:xml:ns:xmpp-stanzas"
|
||||
nsErrorStreams = "urn:ietf:params:xml:ns:xmpp-streams"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -9,11 +9,6 @@ import (
|
|||
"net"
|
||||
)
|
||||
|
||||
const (
|
||||
nsStream = "http://etherx.jabber.org/streams"
|
||||
nsTLS = "urn:ietf:params:xml:ns:xmpp-tls"
|
||||
)
|
||||
|
||||
// Stream configuration.
|
||||
type StreamConfig struct {
|
||||
// Log all sent and received stanzas.
|
||||
|
|
|
|||
Loading…
Reference in New Issue