summaryrefslogtreecommitdiff
path: root/xmpp/routing.go
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp/routing.go')
-rw-r--r--xmpp/routing.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/xmpp/routing.go b/xmpp/routing.go
index e8aa4ed..2b1680f 100644
--- a/xmpp/routing.go
+++ b/xmpp/routing.go
@@ -8,14 +8,17 @@ import (
func route(s *xml.StartElement, d *xml.Decoder, c chan<- any) {
switch (*s).Name {
case xml.Name{`http://etherx.jabber.org/streams`, `features`}:
- data := streamFeatures{}
- err := d.DecodeElement(&data, s)
- if err != nil {
- log.Printf("Could not decode stream features: %v\n", err)
- } else {
- log.Print(data) // TODO
- }
+ parse(streamFeatures{}, s, d, c)
default:
d.Skip()
}
}
+
+func parse[T any](data T, s *xml.StartElement, d *xml.Decoder, c chan<- any) {
+ err := d.DecodeElement(&data, s)
+ if err != nil {
+ log.Printf("Could not decode stream features: %v\n", err)
+ } else {
+ c <- data
+ }
+}