Skip to content

Commit

Permalink
Extract special observe value to constant
Browse files Browse the repository at this point in the history
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
  • Loading branch information
dborovcanin committed Mar 30, 2022
1 parent 51904b9 commit f47413a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions coap/api/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import (
)

const (
protocol = "coap"
authQuery = "auth"
protocol = "coap"
authQuery = "auth"
startObserve = 0 // observe option value that indicates start of observation
)

var channelPartRegExp = regexp.MustCompile(`^/channels/([\w\-]+)/messages(/[^?]*)?(\?.*)?$`)
Expand Down Expand Up @@ -124,7 +125,7 @@ func handleGet(m *mux.Message, c mux.Client, msg messaging.Message, key string)
logger.Warn(fmt.Sprintf("Error reading observe option: %s", err))
return errBadOptions
}
if obs == 0 {
if obs == startObserve {
c := coap.NewClient(c, m.Token, logger)
return service.Subscribe(context.Background(), key, msg.Channel, msg.Subtopic, c)
}
Expand Down

0 comments on commit f47413a

Please sign in to comment.