-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
30 lines (26 loc) · 853 Bytes
/
client.go
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
package main
// import (
// "fmt"
// lib "main/lib/net"
// "main/proto/main/pb"
// )
// func main() {
// router := lib.CreateRouter()
// router.RegisterHandler(int32(pb.PACKET_CMD_LOGIN_RES), func(msg, _ interface{}) interface{} {
// res := msg.(*pb.LoginRes)
// fmt.Println(res.Player.Name, res.Player.Gold, res.Player.Lv)
// return nil
// })
// convert := lib.NewProtoDataConvert()
// convert.RegisterProto(pb.PACKET_CMD_LOGIN_RES, func() interface{} { return &pb.LoginRes{} })
// client := lib.NewTcpClient("127.0.0.1", "8101", router, convert)
// client.Start()
// req := &pb.LoginReq{Base: &pb.BaseMessage{}}
// // cmd := pb.PACKET_CMD_EMPTY
// req.Base.Cmd = pb.PACKET_CMD_LOGIN
// req.Account = "test"
// client.Send(req)
// running := make(chan bool)
// <-running
// close(running)
// }