summaryrefslogtreecommitdiff
path: root/xmpp/stream_pair.go
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp/stream_pair.go')
-rw-r--r--xmpp/stream_pair.go26
1 files changed, 18 insertions, 8 deletions
diff --git a/xmpp/stream_pair.go b/xmpp/stream_pair.go
index c9108d1..693972e 100644
--- a/xmpp/stream_pair.go
+++ b/xmpp/stream_pair.go
@@ -6,8 +6,8 @@ import (
)
func runStreamPair(s *session) {
- openStream(s)
- defer closeStream(s)
+ end := openStream(s)
+ defer closeStream(s, end)
buf := newElementBuffer()
@@ -28,13 +28,13 @@ func runStreamPair(s *session) {
}
if buf.isComplete() {
element := buf.reset()
- route(element, getRoutingTable())
+ route(s, element, getRoutingTable())
}
}
}
}
-func openStream(s *session) {
+func openStream(s *session) xml.EndElement {
start := xml.StartElement{
xml.Name{"jabber:client", "stream:stream"},
[]xml.Attr{
@@ -45,8 +45,7 @@ func openStream(s *session) {
xml.Attr{xml.Name{"", "xmlns:stream"}, "http://etherx.jabber.org/streams"},
},
}
-
- s.streamEnd = start.End()
+ end := start.End()
err := s.ed.encodeToken(start)
if err != nil {
@@ -54,6 +53,8 @@ func openStream(s *session) {
}
syncStreams(s)
+
+ return end
}
// syncStreams drops XML tokens from the receiving stream until an
@@ -84,9 +85,18 @@ func syncStreams(s *session) {
}
}
-func closeStream(s *session) {
- err := s.ed.encodeToken(s.streamEnd)
+func closeStream(s *session, end xml.EndElement) {
+ err := s.ed.encodeToken(end)
if err != nil {
log.Println("Could not encode stream end!")
}
}
+
+func streamFeaturesHandler(s *session, e []xml.Token) {
+ if hasSaslPlain(e) {
+ s.sasl()
+ return
+ }
+
+ log.Println("Stream has no implemented features!")
+}