diff options
author | xengineering <me@xengineering.eu> | 2023-06-30 13:58:53 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-06-30 13:58:53 +0200 |
commit | 2f1fd4d1ce2c0c2e46fcfa1ffedfd84f0d36484e (patch) | |
tree | 8f6177e668c2737705949bc2fed200eb5e19a974 /xmpp/router.go | |
parent | 04746f75ea935266ded4e28edb6ab25c537d50e1 (diff) | |
parent | 3dc04660a87e1b9fabeea0e55a8511d80d34a694 (diff) | |
download | limox-2f1fd4d1ce2c0c2e46fcfa1ffedfd84f0d36484e.tar limox-2f1fd4d1ce2c0c2e46fcfa1ffedfd84f0d36484e.tar.zst limox-2f1fd4d1ce2c0c2e46fcfa1ffedfd84f0d36484e.zip |
Merge branch 'stream-features'
The added code provides a structured way to handle features offered by
the server.
Diffstat (limited to 'xmpp/router.go')
-rw-r--r-- | xmpp/router.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/xmpp/router.go b/xmpp/router.go index 839f870..9d69033 100644 --- a/xmpp/router.go +++ b/xmpp/router.go @@ -12,7 +12,7 @@ import ( // entry of the routingTable. type routingTable []struct { name xml.Name - handler func([]xml.Token) + handler func(*session, []xml.Token) } // getRoutingTable returns the routing table used in @@ -22,14 +22,16 @@ type routingTable []struct { // variable would have the problem that it could be altered during execution. func getRoutingTable() routingTable { return routingTable{ - // TODO fill with entries + {xml.Name{`http://etherx.jabber.org/streams`, `features`}, streamFeaturesHandler}, + {xml.Name{`urn:ietf:params:xml:ns:xmpp-sasl`, `success`}, saslSuccessHandler}, + {xml.Name{`urn:ietf:params:xml:ns:xmpp-sasl`, `failure`}, saslFailureHandler}, } } // route determines the correct handler function for the given XML element by a // given routingTable. In addition it executes the determined handler function. // If no handler function is found an error message is send via the log module. -func route(e []xml.Token, t routingTable) { +func route(s *session, e []xml.Token, t routingTable) { var name xml.Name // TODO a stronger definition of an XML element (as here @@ -50,7 +52,7 @@ func route(e []xml.Token, t routingTable) { for _, r := range t { if name == r.name { - r.handler(e) + r.handler(s, e) return } } |