diff options
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/write.go')
-rw-r--r-- | vendor/github.com/Rhymen/go-whatsapp/write.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/write.go b/vendor/github.com/Rhymen/go-whatsapp/write.go index 1a2f4d7b..74f43c42 100644 --- a/vendor/github.com/Rhymen/go-whatsapp/write.go +++ b/vendor/github.com/Rhymen/go-whatsapp/write.go @@ -30,6 +30,11 @@ func (wac *Conn) writeJson(data []interface{}) (<-chan string, error) { messageTag := fmt.Sprintf("%d.--%d", ts, wac.msgCount) bytes := []byte(fmt.Sprintf("%s,%s", messageTag, d)) + if wac.timeTag == "" { + tss := fmt.Sprintf("%d", ts) + wac.timeTag = tss[len(tss)-3:] + } + ch, err := wac.write(websocket.TextMessage, messageTag, bytes) if err != nil { return nil, err @@ -127,6 +132,9 @@ func (wac *Conn) write(messageType int, answerMessageTag string, data []byte) (< wac.listener.Unlock() } + if wac == nil || wac.ws == nil { + return nil, ErrInvalidWebsocket + } wac.ws.Lock() err := wac.ws.conn.WriteMessage(messageType, data) wac.ws.Unlock() |