client.go
1.96 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
// "os"
pb "common/rpc_world"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
const (
address = "localhost:50055"
// address = "139.196.215.75:50055"
// address = "139.196.215.75:50062"
)
func main() {
conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
c := pb.NewRoomClient(conn)
r, err := c.CreateRoom(context.Background(), &pb.CreateRoomRequest{RoomId: 100000, CreatePlayerId: 999, RoomName: "happyroom", RuleTimeLimit: 3600,
SmallBlind: 2, BuyinMin: 3, PlayerCount: 5})
if err != nil {
log.Fatalf("could not CreateRoom: %v", err)
}
log.Printf("CreateRoom: %s", r.Message)
r1, err1 := c.JoinRoom(context.Background(), &pb.JoinRoomRequest{RoomId: 100001, UserId: 999})
if err1 != nil {
log.Fatalf("could not JoinRoom: %v", err1)
}
log.Printf("CreateRoom: %s", r1.Message)
ret, er := c.ModifyRoomInfo(context.Background(), &pb.ModifyRoomInfoRequest{Id: 100000, PlayerCount: 6})
if er != nil {
log.Fatalf("could not ModifyRoomInfo: %v", er)
}
log.Printf("ModifyRoomInfo: %s", ret.Message)
rt, e := c.DestroyRoom(context.Background(), &pb.DestroyRoomRequest{Id: 100000})
if e != nil {
log.Fatalf("could not DestroyRoom: %v", e)
}
log.Printf("DestroyRoom: %s", rt.Message)
rt1, e1 := c.GetNewRoomID(context.Background(), &pb.GetRoomIDRequest{Name: "阿明"})
if e1 != nil {
log.Fatalf("could not DestroyRoom: %v", e1)
}
log.Printf("GetNewRoomID: %s %d", rt1.RoomUuid, rt1.Roomid, "UuidInt:", rt1.UuidInt)
rt2, e2 := c.CheckClubManager(context.Background(), &pb.CheckClubManagerRequest{Playerid: 100, Clubid: 1000})
if e2 != nil {
log.Fatalf("could not DestroyRoom: %v", e2)
}
log.Printf("CheckClubManager: %d", rt2.Result)
rt3, e3 := c.CheckClubMember(context.Background(), &pb.CheckClubMemberRequest{Playerid: 10, Clubid: 10})
if e3 != nil {
log.Fatalf("could not DestroyRoom: %v", e3)
}
log.Printf("CheckClubMember: %d", rt3.Result)
}