summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Rhymen/go-whatsapp/write.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/write.go')
-rw-r--r--vendor/github.com/Rhymen/go-whatsapp/write.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/write.go b/vendor/github.com/Rhymen/go-whatsapp/write.go
index b3704e4a..1a2f4d7b 100644
--- a/vendor/github.com/Rhymen/go-whatsapp/write.go
+++ b/vendor/github.com/Rhymen/go-whatsapp/write.go
@@ -5,16 +5,22 @@ import (
"crypto/sha256"
"encoding/json"
"fmt"
+ "strconv"
+
+ "time"
+
"github.com/Rhymen/go-whatsapp/binary"
"github.com/Rhymen/go-whatsapp/crypto/cbc"
"github.com/gorilla/websocket"
"github.com/pkg/errors"
- "strconv"
- "time"
)
//writeJson enqueues a json message into the writeChan
func (wac *Conn) writeJson(data []interface{}) (<-chan string, error) {
+
+ wac.writerLock.Lock()
+ defer wac.writerLock.Unlock()
+
d, err := json.Marshal(data)
if err != nil {
return nil, err
@@ -38,6 +44,9 @@ func (wac *Conn) writeBinary(node binary.Node, metric metric, flag flag, message
return nil, ErrMissingMessageTag
}
+ wac.writerLock.Lock()
+ defer wac.writerLock.Unlock()
+
data, err := wac.encryptBinaryMessage(node)
if err != nil {
return nil, errors.Wrap(err, "encryptBinaryMessage(node) failed")