From 0bd5959ef4b933acf64ad27489fd616dcf4825df Mon Sep 17 00:00:00 2001 From: Florimond Husquinet Date: Wed, 13 Mar 2019 04:40:32 +0100 Subject: [PATCH 1/4] Fix onMessage default msg handler condition --- v2/emitter.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/emitter.go b/v2/emitter.go index f7995bc..3fcf322 100644 --- a/v2/emitter.go +++ b/v2/emitter.go @@ -137,9 +137,9 @@ func (c *Client) OnError(handler ErrorHandler) { // onMessage occurs when MQTT client receives a message func (c *Client) onMessage(_ mqtt.Client, m mqtt.Message) { - if c.message != nil && !strings.HasPrefix(m.Topic(), "emitter/") { + if !strings.HasPrefix(m.Topic(), "emitter/") { handlers := c.handlers.Lookup(m.Topic()) - if len(handlers) == 0 { // Invoke the default message handler + if len(handlers) == 0 && c.message != nil { // Invoke the default message handler c.message(c, m) } From a64c9aca4bab172bf3e4a5ded3b38d1b17ae1427 Mon Sep 17 00:00:00 2001 From: Florimond Husquinet Date: Sat, 4 May 2019 13:13:49 +0200 Subject: [PATCH 2/4] WithFrom and WithUntil --- v2/options.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/v2/options.go b/v2/options.go index 56254df..db80863 100644 --- a/v2/options.go +++ b/v2/options.go @@ -149,3 +149,22 @@ func WithAtMostOnce() Option { func WithAtLeastOnce() Option { return withQos1 } + +func getUTCTimestamp(input time.Time) int64 { + t := input + if zone, _ := t.Zone(); zone != "UTC" { + loc, _ := time.LoadLocation("UTC") + t = t.In(loc) + } + return t.Unix() +} + +// WithFrom request messages from a point in time. +func WithFrom(from time.Time) Option { + return option("from=" + strconv.FormatInt(getUTCTimestamp(from), 10)) +} + +// WithUntil request messages until a point in time. +func WithUntil(until time.Time) Option { + return option("from=" + strconv.FormatInt(getUTCTimestamp(until), 10)) +} From befb623e1183f095478b3783d279d6bd8dcab467 Mon Sep 17 00:00:00 2001 From: Florimond Husquinet Date: Mon, 27 May 2019 18:22:49 +0200 Subject: [PATCH 3/4] Fix WithUntil --- v2/options.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/options.go b/v2/options.go index db80863..6479d16 100644 --- a/v2/options.go +++ b/v2/options.go @@ -166,5 +166,5 @@ func WithFrom(from time.Time) Option { // WithUntil request messages until a point in time. func WithUntil(until time.Time) Option { - return option("from=" + strconv.FormatInt(getUTCTimestamp(until), 10)) + return option("until=" + strconv.FormatInt(getUTCTimestamp(until), 10)) } From 540049cd23809e2f1f59d48fdc958ef2d0351a4b Mon Sep 17 00:00:00 2001 From: Roman Atachiants Date: Fri, 1 Nov 2019 09:33:57 +0800 Subject: [PATCH 4/4] Create FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..2dfd7ad --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [kelindar]