fix
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/server/websocket/internal/types"
|
||||
"github.com/google/uuid"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -32,12 +34,24 @@ func NewDataTransferLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Data
|
||||
}
|
||||
|
||||
var (
|
||||
//升级
|
||||
buffPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return bytes.Buffer{}
|
||||
},
|
||||
}
|
||||
//升级websocket
|
||||
upgrade = websocket.Upgrader{
|
||||
//握手超时时间15s
|
||||
HandshakeTimeout: time.Second * 15,
|
||||
//允许跨域
|
||||
CheckOrigin: func(r *http.Request) bool {
|
||||
return true
|
||||
},
|
||||
Error: func(w http.ResponseWriter, r *http.Request, status int, reason error) {
|
||||
httpx.ErrorCtx(r.Context(), w, reason)
|
||||
return
|
||||
},
|
||||
WriteBufferPool: &buffPool,
|
||||
}
|
||||
//连接map池
|
||||
mapConnPool = sync.Map{}
|
||||
|
||||
Reference in New Issue
Block a user