fix
This commit is contained in:
parent
a19d526e72
commit
04982bae18
@ -80,6 +80,9 @@ type wsConnectItem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) {
|
func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) {
|
||||||
|
token := r.Header.Get("Sec-Websocket-Protocol")
|
||||||
|
//设置Sec-Websocket-Protocol
|
||||||
|
upgrade.Subprotocols = []string{token}
|
||||||
//升级websocket
|
//升级websocket
|
||||||
conn, err := upgrade.Upgrade(w, r, nil)
|
conn, err := upgrade.Upgrade(w, r, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -88,10 +91,11 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
//鉴权不成功后断开
|
//鉴权不成功后断开
|
||||||
/*var (
|
var (
|
||||||
userInfo *auth.UserInfo
|
userInfo *auth.UserInfo
|
||||||
isAuth bool
|
isAuth bool
|
||||||
)
|
)
|
||||||
|
fmt.Println("###################:", r.Header)
|
||||||
isAuth, userInfo = l.checkAuth(r)
|
isAuth, userInfo = l.checkAuth(r)
|
||||||
if !isAuth {
|
if !isAuth {
|
||||||
time.Sleep(time.Second * 1) //兼容下火狐
|
time.Sleep(time.Second * 1) //兼容下火狐
|
||||||
@ -105,12 +109,12 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request)
|
|||||||
//发送关闭信息
|
//发送关闭信息
|
||||||
_ = conn.WriteMessage(websocket.CloseMessage, nil)
|
_ = conn.WriteMessage(websocket.CloseMessage, nil)
|
||||||
return
|
return
|
||||||
}*/
|
}
|
||||||
// todo user信息是没有的
|
// todo user信息是没有的
|
||||||
var userInfo auth.UserInfo
|
/*var userInfo auth.UserInfo
|
||||||
userInfo.UserId = 39
|
userInfo.UserId = 39*/
|
||||||
//设置连接
|
//设置连接
|
||||||
ws := l.setConnPool(conn, userInfo)
|
ws := l.setConnPool(conn, *userInfo)
|
||||||
defer ws.close()
|
defer ws.close()
|
||||||
//循环读客户端信息
|
//循环读客户端信息
|
||||||
go ws.readLoop()
|
go ws.readLoop()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user