初始
This commit is contained in:
32
api/pilot/ws/ws.go
Normal file
32
api/pilot/ws/ws.go
Normal file
@ -0,0 +1,32 @@
|
||||
package ws
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
type WS struct {
|
||||
}
|
||||
|
||||
type WsReq struct {
|
||||
g.Meta `path:"ws2" summary:"ws2" method:"get" tags:"无人机"`
|
||||
}
|
||||
|
||||
type UsualRes struct {
|
||||
}
|
||||
|
||||
func (receiver *WS) WSConnect(ctx context.Context, req *WsReq) (res *UsualRes, err error) {
|
||||
r := ghttp.RequestFromCtx(ctx)
|
||||
ws, err := r.WebSocket()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for {
|
||||
_, _, err := ws.ReadMessage()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//fmt.Println(msgType, string(msg))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user