Renamed Extension.StanzaHandlers to StanzaTypes, and updated the doc comment.
authorChris Jones <chris@cjones.org>
Sun, 29 Sep 2013 21:37:14 -0600
changeset 158 2d948fcbb5d7
parent 157 eadf15a06ff5
child 159 fd4089f717b2
Renamed Extension.StanzaHandlers to StanzaTypes, and updated the doc comment.
TODO.txt
xmpp/roster.go
xmpp/structs.go
xmpp/xmpp.go
--- a/TODO.txt	Sun Sep 29 21:33:03 2013 -0600
+++ b/TODO.txt	Sun Sep 29 21:37:14 2013 -0600
@@ -5,8 +5,6 @@
 
 Eliminate as many uses of Generic as possible.
 
-Rename extension.StanzaHandlers to something like StanzaTypes.
-
 Think about how to gracefully shutdown. Probably have a Close()
 function.
 
--- a/xmpp/roster.go	Sun Sep 29 21:33:03 2013 -0600
+++ b/xmpp/roster.go	Sun Sep 29 21:37:14 2013 -0600
@@ -103,9 +103,9 @@
 
 func newRosterExt() *Roster {
 	r := Roster{}
-	r.StanzaHandlers = make(map[xml.Name]reflect.Type)
+	r.StanzaTypes = make(map[xml.Name]reflect.Type)
 	rName := xml.Name{Space: NsRoster, Local: "query"}
-	r.StanzaHandlers[rName] = reflect.TypeOf(RosterQuery{})
+	r.StanzaTypes[rName] = reflect.TypeOf(RosterQuery{})
 	r.RecvFilter, r.SendFilter = r.makeFilters()
 	r.get = make(chan []RosterItem)
 	r.toServer = make(chan Stanza)
--- a/xmpp/structs.go	Sun Sep 29 21:33:03 2013 -0600
+++ b/xmpp/structs.go	Sun Sep 29 21:37:14 2013 -0600
@@ -269,7 +269,7 @@
 var bindExt Extension = Extension{}
 
 func init() {
-	bindExt.StanzaHandlers = make(map[xml.Name]reflect.Type)
+	bindExt.StanzaTypes = make(map[xml.Name]reflect.Type)
 	bName := xml.Name{Space: NsBind, Local: "bind"}
-	bindExt.StanzaHandlers[bName] = reflect.TypeOf(bindIq{})
+	bindExt.StanzaTypes[bName] = reflect.TypeOf(bindIq{})
 }
--- a/xmpp/xmpp.go	Sun Sep 29 21:33:03 2013 -0600
+++ b/xmpp/xmpp.go	Sun Sep 29 21:37:14 2013 -0600
@@ -76,10 +76,9 @@
 
 // Extensions can add stanza filters and/or new XML element types.
 type Extension struct {
-	// Maps from an XML namespace to a function which constructs a
-	// structure to hold the contents of stanzas in that
-	// namespace.
-	StanzaHandlers map[xml.Name]reflect.Type
+	// Maps from an XML name to a structure which holds stanza
+	// contents with that name.
+	StanzaTypes 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
@@ -140,7 +139,7 @@
 
 	extStanza := make(map[xml.Name]reflect.Type)
 	for _, ext := range exts {
-		for k, v := range ext.StanzaHandlers {
+		for k, v := range ext.StanzaTypes {
 			if _, ok := extStanza[k]; ok {
 				return nil, fmt.Errorf("duplicate handler %s",
 					k)