client.go
831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"github.com/golang/protobuf/proto"
"pro2d/common"
"pro2d/common/components"
"pro2d/common/logger"
"pro2d/pb"
"time"
)
func main() {
head := &components.PBHead{
Length: 0,
Cmd: uint32(pb.ProtoCode_LoginReq),
ErrCode: 0,
PreField: 0,
}
loginReq := &pb.LoginReq{
Token: "141815055745814528",
Device: "123123",
}
l, _ := proto.Marshal(loginReq)
options := []components.ConnectorOption{
components.WithCtorCount(common.GlobalConf.TestClient.Count),
components.WithCtorSplitter(components.NewPBSplitter(nil)),
}
client := components.NewConnector(common.GlobalConf.TestClient.Ip, common.GlobalConf.TestClient.Port, options...)
if err := client.Connect(); err != nil {
logger.Error(err)
return
}
for {
client.Send(head.Cmd, l)
time.Sleep(1 * time.Second)
}
}