equal
deleted
inserted
replaced
74 // should close its output when its input is closed. |
74 // should close its output when its input is closed. |
75 type Filter func(in <-chan Stanza, out chan<- Stanza) |
75 type Filter func(in <-chan Stanza, out chan<- Stanza) |
76 |
76 |
77 // Extensions can add stanza filters and/or new XML element types. |
77 // Extensions can add stanza filters and/or new XML element types. |
78 type Extension struct { |
78 type Extension struct { |
79 // Maps from an XML namespace to a function which constructs a |
79 // Maps from an XML name to a structure which holds stanza |
80 // structure to hold the contents of stanzas in that |
80 // contents with that name. |
81 // namespace. |
81 StanzaTypes map[xml.Name]reflect.Type |
82 StanzaHandlers map[xml.Name]reflect.Type |
|
83 // If non-nil, will be called once to start the filter |
82 // If non-nil, will be called once to start the filter |
84 // running. RecvFilter intercepts incoming messages on their |
83 // running. RecvFilter intercepts incoming messages on their |
85 // way from the remote server to the application; SendFilter |
84 // way from the remote server to the application; SendFilter |
86 // intercepts messages going the other direction. |
85 // intercepts messages going the other direction. |
87 RecvFilter Filter |
86 RecvFilter Filter |
138 cl.recvFilterAdd = make(chan Filter) |
137 cl.recvFilterAdd = make(chan Filter) |
139 cl.statmgr = newStatmgr(status) |
138 cl.statmgr = newStatmgr(status) |
140 |
139 |
141 extStanza := make(map[xml.Name]reflect.Type) |
140 extStanza := make(map[xml.Name]reflect.Type) |
142 for _, ext := range exts { |
141 for _, ext := range exts { |
143 for k, v := range ext.StanzaHandlers { |
142 for k, v := range ext.StanzaTypes { |
144 if _, ok := extStanza[k]; ok { |
143 if _, ok := extStanza[k]; ok { |
145 return nil, fmt.Errorf("duplicate handler %s", |
144 return nil, fmt.Errorf("duplicate handler %s", |
146 k) |
145 k) |
147 } |
146 } |
148 extStanza[k] = v |
147 extStanza[k] = v |