mirror of
https://github.com/statbate/shiny-potato.git
synced 2026-08-11 03:12:42 +00:00
update
This commit is contained in:
parent
ac13a3fab3
commit
1f059fad30
1 changed files with 21 additions and 7 deletions
|
|
@ -144,6 +144,15 @@ func getToken(room string) string {
|
||||||
return string(bytes.ReplaceAll(m[1], []byte(`\u002F`), []byte(`/`)))
|
return string(bytes.ReplaceAll(m[1], []byte(`\u002F`), []byte(`/`)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reconnectRoom(workerData Info) {
|
||||||
|
n := randInt(10, 30)
|
||||||
|
fmt.Printf("Sleeping %d seconds...\n", n)
|
||||||
|
time.Sleep(time.Duration(n) * time.Second)
|
||||||
|
fmt.Println("reconnect:", workerData.room, workerData.Id, workerData.Proxy)
|
||||||
|
workerData.Last = time.Now().Unix()
|
||||||
|
startRoom(workerData)
|
||||||
|
}
|
||||||
|
|
||||||
func xWorker(workerData Info) {
|
func xWorker(workerData Info) {
|
||||||
fmt.Println("Start", workerData.room, "id", workerData.Id, "proxy", workerData.Proxy)
|
fmt.Println("Start", workerData.room, "id", workerData.Id, "proxy", workerData.Proxy)
|
||||||
|
|
||||||
|
|
@ -153,16 +162,18 @@ func xWorker(workerData Info) {
|
||||||
rooms.Del <- workerData.room
|
rooms.Del <- workerData.room
|
||||||
}()
|
}()
|
||||||
|
|
||||||
xurl := workerData.Server
|
if workerData.Server == "" {
|
||||||
|
workerData.Server = getToken(workerData.room)
|
||||||
if xurl == "" {
|
}
|
||||||
xurl = getToken(workerData.room)
|
|
||||||
workerData.Server = xurl
|
if len(workerData.Server) < 50 {
|
||||||
|
fmt.Println(workerData.Server, workerData.room)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
u, err := url.Parse(xurl)
|
u, err := url.Parse(workerData.Server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(xurl, err, workerData.room)
|
fmt.Println(err, workerData.room)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,6 +209,9 @@ func xWorker(workerData Info) {
|
||||||
_, message, err := c.ReadMessage()
|
_, message, err := c.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error(), workerData.room)
|
fmt.Println(err.Error(), workerData.room)
|
||||||
|
if workerData.Income > 1 && websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
|
||||||
|
reconnectRoom(workerData)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue