From c1da50ce26f2c59d48784c119a971c2923506fa8 Mon Sep 17 00:00:00 2001 From: Matt Goodall Date: Mon, 16 Jul 2012 17:24:48 +0100 Subject: [PATCH] Organise code into better logical groups. --- src/xmpp/xmpp.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/xmpp/xmpp.go b/src/xmpp/xmpp.go index 5f79df0..05f76bb 100644 --- a/src/xmpp/xmpp.go +++ b/src/xmpp/xmpp.go @@ -58,12 +58,33 @@ func (x *XMPP) SendRecv(iq *Iq) (*Iq, error) { return reply, nil } +// Interface used to test if a stanza matches some application-defined +// conditions. +type Matcher interface { + // Return true if the stanza, v, matches. + Match(v interface{}) (match bool) +} + +// Adapter to allow a plain func to be used as a Matcher. +type MatcherFunc func(v interface{}) bool + +// Implement Matcher by calling the adapted func. +func (fn MatcherFunc) Match(v interface{}) bool { + return fn(v) +} + type FilterId int64 func (fid FilterId) Error() string { return fmt.Sprintf("Invalid filter id: %d", fid) } +type filter struct { + id FilterId + m Matcher + ch chan interface{} +} + func (x *XMPP) AddFilter(m Matcher) (FilterId, chan interface{}) { // Protect against concurrent access. @@ -127,27 +148,6 @@ func IqResult(id string) Matcher { ) } -// Interface used to test if a stanza matches some application-defined -// conditions. -type Matcher interface { - // Return true if the stanza, v, matches. - Match(v interface{}) (match bool) -} - -// Adapter to allow a plain func to be used as a Matcher. -type MatcherFunc func(v interface{}) bool - -// Implement Matcher by calling the adapted func. -func (fn MatcherFunc) Match(v interface{}) bool { - return fn(v) -} - -type filter struct { - id FilterId - m Matcher - ch chan interface{} -} - func (x *XMPP) sender() { for v := range x.Out { x.stream.Send(v)