feat 排队

This commit is contained in:
2026-01-06 18:36:19 +08:00
parent fdb4798b36
commit 2e1a418485
10 changed files with 214 additions and 34 deletions

View File

@@ -1,19 +1,19 @@
package ws
import (
"common/utils"
"robot/config"
"strconv"
"time"
)
type Manager struct {
addr string
httpAddr string
websocketAddr string
}
func NewManager(addr string) *Manager {
func NewManager(httpAddr, websocketAddr string) *Manager {
c := &Manager{
addr: addr,
httpAddr: httpAddr,
websocketAddr: websocketAddr,
}
return c
}
@@ -21,8 +21,7 @@ func NewManager(addr string) *Manager {
func (c *Manager) Start() {
cfg := config.Get().Client
for i := int32(0); i < cfg.Count; i++ {
client := NewClient(c.addr, strconv.Itoa(utils.RandInt(int(cfg.USN[0]), int(cfg.USN[1]))))
client.Start()
NewClient(c.httpAddr, c.websocketAddr).Start()
time.Sleep(time.Millisecond * 10)
}
}