|
|
@ -81,10 +81,15 @@ func (ws *wsconn) Write(b []byte) (n int, err error) {
|
|
|
|
ws.wlock.Lock()
|
|
|
|
ws.wlock.Lock()
|
|
|
|
|
|
|
|
|
|
|
|
if ws.connClosing {
|
|
|
|
if ws.connClosing {
|
|
|
|
|
|
|
|
|
|
|
|
return 0, io.EOF
|
|
|
|
return 0, io.EOF
|
|
|
|
}
|
|
|
|
}
|
|
|
|
writeWs := func(b []byte) (n int, err error) {
|
|
|
|
|
|
|
|
|
|
|
|
n, err = ws.write(b)
|
|
|
|
|
|
|
|
ws.wlock.Unlock()
|
|
|
|
|
|
|
|
return n, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (ws *wsconn) write(b []byte) (n int, err error) {
|
|
|
|
wr, err := ws.wsc.NextWriter(websocket.BinaryMessage)
|
|
|
|
wr, err := ws.wsc.NextWriter(websocket.BinaryMessage)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Warning("WS transport: ws connection NewFrameReader return " + err.Error())
|
|
|
|
log.Warning("WS transport: ws connection NewFrameReader return " + err.Error())
|
|
|
@ -102,10 +107,7 @@ func (ws *wsconn) Write(b []byte) (n int, err error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return n, err
|
|
|
|
return n, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
n, err = writeWs(b)
|
|
|
|
|
|
|
|
ws.wlock.Unlock()
|
|
|
|
|
|
|
|
return n, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ws *wsconn) Close() error {
|
|
|
|
func (ws *wsconn) Close() error {
|
|
|
|
ws.connClosing = true
|
|
|
|
ws.connClosing = true
|
|
|
|
ws.wlock.Lock()
|
|
|
|
ws.wlock.Lock()
|
|
|
|