Timeout after unclock device
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func sendCommand(mutex *sync.Mutex, command string, channel, value, r, g, b int) error {
|
func sendCommand(mutex *sync.Mutex, command string, channel, value, r, g, b int) error {
|
||||||
@@ -20,8 +21,15 @@ func sendCommand(mutex *sync.Mutex, command string, channel, value, r, g, b int)
|
|||||||
return errors.New("Command was not set")
|
return errors.New("Command was not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.Lock()
|
mutex.Lock() // Lock for sync call
|
||||||
defer mutex.Unlock()
|
|
||||||
|
timedUnlock := func(m *sync.Mutex) {
|
||||||
|
time.Sleep(time.Millisecond * 200) // Without timeout not worked
|
||||||
|
m.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
defer timedUnlock(mutex)
|
||||||
|
|
||||||
n, err := noolite.DefaultNooliteAdapter()
|
n, err := noolite.DefaultNooliteAdapter()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user