aboutsummaryrefslogtreecommitdiffstats
path: root/event
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-17 02:55:57 +0800
committerobscuren <geffobscura@gmail.com>2014-12-17 02:55:57 +0800
commit52b54631a47dfa46742635be178f2f8d33dd9f41 (patch)
tree5d99624cd5df30c9747039dd874559a974af9bdd /event
parent93edae280d60d217084430a0c6c16f648c82732e (diff)
downloadgo-tangerine-52b54631a47dfa46742635be178f2f8d33dd9f41.tar.gz
go-tangerine-52b54631a47dfa46742635be178f2f8d33dd9f41.tar.zst
go-tangerine-52b54631a47dfa46742635be178f2f8d33dd9f41.zip
Whisper watches fixes
Diffstat (limited to 'event')
-rw-r--r--event/filter/generic_filter.go20
1 files changed, 15 insertions, 5 deletions
diff --git a/event/filter/generic_filter.go b/event/filter/generic_filter.go
index b04b4801e..2ce0f0642 100644
--- a/event/filter/generic_filter.go
+++ b/event/filter/generic_filter.go
@@ -2,19 +2,29 @@ package filter
type Generic struct {
Str1, Str2, Str3 string
+ Data map[string]struct{}
Fn func(data interface{})
}
+// self = registered, f = incoming
func (self Generic) Compare(f Filter) bool {
+ var strMatch, dataMatch = true, true
+
filter := f.(Generic)
- if (len(self.Str1) == 0 || filter.Str1 == self.Str1) &&
- (len(self.Str2) == 0 || filter.Str2 == self.Str2) &&
- (len(self.Str3) == 0 || filter.Str3 == self.Str3) {
- return true
+ if (len(self.Str1) > 0 && filter.Str1 != self.Str1) ||
+ (len(self.Str2) > 0 && filter.Str2 != self.Str2) ||
+ (len(self.Str3) > 0 && filter.Str3 != self.Str3) {
+ strMatch = false
+ }
+
+ for k, _ := range self.Data {
+ if _, ok := filter.Data[k]; !ok {
+ return false
+ }
}
- return false
+ return strMatch && dataMatch
}
func (self Generic) Trigger(data interface{}) {