🚀 dashboard v0.14.7 with agent v0.14.4

This commit is contained in:
naiba
2022-11-01 21:46:02 +08:00
parent e36fae2da1
commit ab5b6eddf0
8 changed files with 47 additions and 12 deletions

View File

@@ -0,0 +1,25 @@
package websocketx
import (
"sync"
"github.com/gorilla/websocket"
"github.com/samber/lo"
)
type Conn struct {
*websocket.Conn
writeLock sync.Mutex
}
func (conn *Conn) WriteMessage(msgType int, data []byte) error {
conn.writeLock.Lock()
defer conn.writeLock.Unlock()
var err error
lo.TryCatchWithErrorValue(func() error {
return conn.Conn.WriteMessage(msgType, data)
}, func(res any) {
err = res.(error)
})
return err
}