--- a/xmpp/xmpp.go Sat Sep 07 10:30:22 2013 -0700
+++ b/xmpp/xmpp.go Sat Sep 07 11:19:29 2013 -0700
@@ -18,6 +18,7 @@
"fmt"
"io"
"net"
+ "reflect"
"sync"
)
@@ -51,7 +52,7 @@
// Maps from an XML namespace to a function which constructs a
// structure to hold the contents of stanzas in that
// namespace.
- StanzaHandlers map[string]func(*xml.Name) interface{}
+ StanzaHandlers map[xml.Name]reflect.Type
// If non-nil, will be called once to start the filter
// running. RecvFilter intercepts incoming messages on their
// way from the remote server to the application; SendFilter
@@ -91,7 +92,7 @@
// asynchronously as new features are received throughout the
// connection process. It should not be updated once
// StartSession() returns.
- Features *Features
+ Features *Features
sendFilterAdd, recvFilterAdd chan Filter
}
@@ -141,9 +142,13 @@
cl.handlers = make(chan *stanzaHandler, 100)
cl.inputControl = make(chan int)
- extStanza := make(map[string]func(*xml.Name) interface{})
+ extStanza := make(map[xml.Name]reflect.Type)
for _, ext := range exts {
for k, v := range ext.StanzaHandlers {
+ if _, ok := extStanza[k]; !ok {
+ return nil, fmt.Errorf("duplicate handler %s",
+ k)
+ }
extStanza[k] = v
}
}