1. 需要改为一个Chrome一个任务. 因为有全局的cookie.
如果开相同的网站会导致cookie混乱.
This commit is contained in:
2021-05-08 18:15:29 +08:00
parent 32fcc9deb3
commit fa568b53c4
5 changed files with 47 additions and 43 deletions

View File

@@ -9,12 +9,6 @@ import (
"github.com/gorilla/websocket"
)
var upGrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
var RemoteAddress = ":12203"
func init() {
@@ -34,6 +28,12 @@ func main() {
eg.POST("queue", PostPushQueue)
eg.GET("task", func(c *gin.Context) {
var upGrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
}
//升级get请求为webSocket协议
ws, err := upGrader.Upgrade(c.Writer, c.Request, nil)
if err != nil {
@@ -54,7 +54,7 @@ func main() {
//读取ws中的数据
log.Println(
"123",
"start task",
)
task := taskQueue.PopBlock()

View File

@@ -87,3 +87,21 @@ func TestTaskPostPushQueue(t *testing.T) {
}
log.Println(string(resp.Content()))
}
func TestBoss(t *testing.T) {
temp := requests.NewSession().Post("http://localhost" + RemoteAddress + "/queue")
task := &Task{
Name: "boss",
Type: 1,
CreateAt: time.Now(),
Info: gin.H{
"data": "boss",
},
}
temp.SetBodyAuto(task)
resp, err := temp.Execute()
if err != nil {
t.Error(err)
}
log.Println(string(resp.Content()))
}