|
@@ -13,7 +13,7 @@ import (
|
|
"github.com/gorilla/websocket"
|
|
"github.com/gorilla/websocket"
|
|
)
|
|
)
|
|
|
|
|
|
-func NewSocket(conn *websocket.Conn) *Socket {
|
|
|
|
|
|
+func NewSocket(conn *websocket.Conn, pingEnable bool) *Socket {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
ws := &Socket{
|
|
ws := &Socket{
|
|
conn: conn,
|
|
conn: conn,
|
|
@@ -22,7 +22,7 @@ func NewSocket(conn *websocket.Conn) *Socket {
|
|
cancel: cancel,
|
|
cancel: cancel,
|
|
writeLocker: &sync.Mutex{},
|
|
writeLocker: &sync.Mutex{},
|
|
chIn: make(chan *rest.RequestStream, 10),
|
|
chIn: make(chan *rest.RequestStream, 10),
|
|
- pingEnable: true,
|
|
|
|
|
|
+ pingEnable: pingEnable,
|
|
}
|
|
}
|
|
ws.lastWrite.Store(time.Now().Unix())
|
|
ws.lastWrite.Store(time.Now().Unix())
|
|
go ws.read()
|
|
go ws.read()
|