From dde0afb688eff58592bbaa0cf5f08ea260b5b907 Mon Sep 17 00:00:00 2001 From: Matt Goodall Date: Mon, 16 Jul 2012 17:32:42 +0100 Subject: [PATCH] Document more of the XMPP API. --- src/xmpp/xmpp.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/xmpp/xmpp.go b/src/xmpp/xmpp.go index 05f76bb..6dc75b7 100644 --- a/src/xmpp/xmpp.go +++ b/src/xmpp/xmpp.go @@ -73,8 +73,11 @@ func (fn MatcherFunc) Match(v interface{}) bool { return fn(v) } +// Uniquly identifies a stream fiter. Used to remove a filter that's no longer +// needed. type FilterId int64 +// Implements the error interface for a FilterId. func (fid FilterId) Error() string { return fmt.Sprintf("Invalid filter id: %d", fid) } @@ -85,6 +88,9 @@ type filter struct { ch chan interface{} } +// Add a filter that routes matching stanzas to the returned channel. A +// FilterId is also returned and can be pased to RemoveFilter to remove the +// filter again. func (x *XMPP) AddFilter(m Matcher) (FilterId, chan interface{}) { // Protect against concurrent access. @@ -105,6 +111,7 @@ func (x *XMPP) AddFilter(m Matcher) (FilterId, chan interface{}) { return id, ch } +// Remove a filter previously added with AddFilter. func (x *XMPP) RemoveFilter(id FilterId) error { // Protect against concurrent access. @@ -133,6 +140,8 @@ func (x *XMPP) RemoveFilter(id FilterId) error { return id } +// Matcher to identify a stanza with the given +// id. func IqResult(id string) Matcher { return MatcherFunc( func(v interface{}) bool {