Browse Source

balance persist

master
tangmingyou 3 years ago
parent
commit
8df5d3d1b0
  1. 4
      README.md
  2. 3
      api/operation.go
  3. 424
      api/poker.pb.go
  4. 9
      api/poker.proto
  5. 401
      api/proto.js
  6. 2
      internal/game/actions.go
  7. 12
      internal/logic/account.go
  8. 53
      internal/logic/auth.go
  9. 94
      internal/logic/balance/balance.go
  10. 8
      internal/logic/delayer/offline.go
  11. 10
      internal/server/ws.go
  12. 2
      internal/server/wsroute.go
  13. 10
      internal/session/net_account.go
  14. 60
      tool/async/concurrent_limiter.go
  15. 4
      tool/async/delay_queue.go

4
README.md

@ -17,7 +17,7 @@ pbjs -t json api/*.proto > jsproto.json
[网易德州扑克规则](http://sports.163.com/special/poker_rule/?ivk_sa=1025883k) [网易德州扑克规则](http://sports.163.com/special/poker_rule/?ivk_sa=1025883k)
cd target cd target
nohup ./texas -conf=config.toml -region=sh -zone=sh001 -deploy.env=dev -weight=10 2>&1 > texas.log & nohup ./texas -conf=config.toml 2>&1 > texas.log &
pkill -f ./texas pkill -f ./texas
@ -27,7 +27,7 @@ TODO List
- 下注页面倒计时、超时自动操作 - 下注页面倒计时、超时自动操作
- 前端lobby页面显示内容优化 - 前端lobby页面显示内容优化
- lobby界面用户创建新桌面时通知消息,前端拉取新大厅界面, - lobby界面用户创建新桌面时通知消息,前端拉取新大厅界面,
- header头部编辑、退出、账户金额,流水 - header头部编辑、退出、账户金额,流水
- 日志 - 日志
- 验证码 - 验证码
- 性能测试、系统调优 - 性能测试、系统调优

3
api/operation.go

@ -53,6 +53,9 @@ var protoInstances = []proto.Message{
&ResCalcWinnerChip{}, &ResCalcWinnerChip{},
&ResGameEndSettle{}, &ResGameEndSettle{},
&ReqAccountBalance{},
&ResAccountBalance{},
} }
var ( var (

424
api/poker.pb.go

@ -364,6 +364,7 @@ type ResIdentity struct {
Id int64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` Id int64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"`
Username string `protobuf:"bytes,4,opt,name=username,proto3" json:"username,omitempty"` Username string `protobuf:"bytes,4,opt,name=username,proto3" json:"username,omitempty"`
Avatar string `protobuf:"bytes,5,opt,name=avatar,proto3" json:"avatar,omitempty"` Avatar string `protobuf:"bytes,5,opt,name=avatar,proto3" json:"avatar,omitempty"`
Balance int32 `protobuf:"varint,6,opt,name=balance,proto3" json:"balance,omitempty"`
} }
func (x *ResIdentity) Reset() { func (x *ResIdentity) Reset() {
@ -419,6 +420,13 @@ func (x *ResIdentity) GetAvatar() string {
return "" return ""
} }
func (x *ResIdentity) GetBalance() int32 {
if x != nil {
return x.Balance
}
return 0
}
// 大厅消息 ============= begin // 大厅消息 ============= begin
type ReqLobbyView struct { type ReqLobbyView struct {
state protoimpl.MessageState state protoimpl.MessageState
@ -1998,6 +2006,91 @@ func (x *ResGameNextRound) GetRound() int32 {
return 0 return 0
} }
type ReqAccountBalance struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *ReqAccountBalance) Reset() {
*x = ReqAccountBalance{}
if protoimpl.UnsafeEnabled {
mi := &file_poker_proto_msgTypes[35]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ReqAccountBalance) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ReqAccountBalance) ProtoMessage() {}
func (x *ReqAccountBalance) ProtoReflect() protoreflect.Message {
mi := &file_poker_proto_msgTypes[35]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ReqAccountBalance.ProtoReflect.Descriptor instead.
func (*ReqAccountBalance) Descriptor() ([]byte, []int) {
return file_poker_proto_rawDescGZIP(), []int{35}
}
type ResAccountBalance struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Balance int32 `protobuf:"varint,1,opt,name=balance,proto3" json:"balance,omitempty"`
}
func (x *ResAccountBalance) Reset() {
*x = ResAccountBalance{}
if protoimpl.UnsafeEnabled {
mi := &file_poker_proto_msgTypes[36]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ResAccountBalance) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ResAccountBalance) ProtoMessage() {}
func (x *ResAccountBalance) ProtoReflect() protoreflect.Message {
mi := &file_poker_proto_msgTypes[36]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ResAccountBalance.ProtoReflect.Descriptor instead.
func (*ResAccountBalance) Descriptor() ([]byte, []int) {
return file_poker_proto_rawDescGZIP(), []int{36}
}
func (x *ResAccountBalance) GetBalance() int32 {
if x != nil {
return x.Balance
}
return 0
}
var File_poker_proto protoreflect.FileDescriptor var File_poker_proto protoreflect.FileDescriptor
var file_poker_proto_rawDesc = []byte{ var file_poker_proto_rawDesc = []byte{
@ -2021,157 +2114,162 @@ var file_poker_proto_rawDesc = []byte{
0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
0x6d, 0x73, 0x67, 0x22, 0x23, 0x0a, 0x0b, 0x52, 0x65, 0x71, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x6d, 0x73, 0x67, 0x22, 0x23, 0x0a, 0x0b, 0x52, 0x65, 0x71, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69,
0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x51, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x49, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x6b, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x49,
0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20,
0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e,
0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x05, 0x20, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x05, 0x20,
0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x62,
0x65, 0x71, 0x4c, 0x6f, 0x62, 0x62, 0x79, 0x56, 0x69, 0x65, 0x77, 0x22, 0x57, 0x0a, 0x0c, 0x52, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x62, 0x61,
0x65, 0x73, 0x4c, 0x6f, 0x62, 0x62, 0x79, 0x56, 0x69, 0x65, 0x77, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x65, 0x71, 0x4c, 0x6f, 0x62, 0x62,
0x75, 0x72, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x79, 0x56, 0x69, 0x65, 0x77, 0x22, 0x57, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x4c, 0x6f, 0x62, 0x62,
0x0a, 0x63, 0x75, 0x72, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x12, 0x27, 0x0a, 0x06, 0x74, 0x79, 0x56, 0x69, 0x65, 0x77, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x75, 0x72, 0x54, 0x61, 0x62, 0x6c,
0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x65, 0x4e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x75, 0x72, 0x54, 0x61,
0x69, 0x2e, 0x4c, 0x6f, 0x62, 0x62, 0x79, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x12, 0x27, 0x0a, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18,
0x62, 0x6c, 0x65, 0x73, 0x22, 0x8c, 0x01, 0x0a, 0x0a, 0x4c, 0x6f, 0x62, 0x62, 0x79, 0x54, 0x61, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x62, 0x62,
0x62, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x18, 0x01, 0x79, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x06, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x22, 0x8c,
0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x12, 0x1c, 0x0a, 0x01, 0x0a, 0x0a, 0x4c, 0x6f, 0x62, 0x62, 0x79, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x18, 0x0a,
0x09, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07,
0x52, 0x09, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x6c, 0x61, 0x79, 0x65,
0x6f, 0x62, 0x6f, 0x74, 0x4e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x72, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x6c, 0x61, 0x79,
0x6f, 0x62, 0x6f, 0x74, 0x4e, 0x75, 0x6d, 0x12, 0x2a, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x65, 0x72, 0x4e, 0x75, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x4e, 0x75,
0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x4e, 0x75,
0x6f, 0x62, 0x62, 0x79, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x6d, 0x12, 0x2a, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03,
0x65, 0x72, 0x73, 0x22, 0x67, 0x0a, 0x0b, 0x4c, 0x6f, 0x62, 0x62, 0x79, 0x50, 0x6c, 0x61, 0x79, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x6f, 0x62, 0x62, 0x79, 0x50, 0x6c,
0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x61, 0x79, 0x65, 0x72, 0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x22, 0x67, 0x0a,
0x08, 0x52, 0x05, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x0b, 0x4c, 0x6f, 0x62, 0x62, 0x79, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05,
0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x6f, 0x62,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6f, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02,
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x04, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x22, 0x7c, 0x0a, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16,
0x52, 0x65, 0x71, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x22, 0x7c, 0x0a, 0x0e, 0x52, 0x65, 0x71, 0x43, 0x72, 0x65,
0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x6f, 0x62, 0x6f, 0x61, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79,
0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65,
0x12, 0x1c, 0x0a, 0x09, 0x74, 0x65, 0x78, 0x61, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x72, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01,
0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x65, 0x78, 0x61, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x28, 0x05, 0x52, 0x06, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x65,
0x0a, 0x08, 0x62, 0x69, 0x67, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x78, 0x61, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74,
0x52, 0x08, 0x62, 0x69, 0x67, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x22, 0x2a, 0x0a, 0x0e, 0x52, 0x65, 0x65, 0x78, 0x61, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x69, 0x67, 0x42,
0x73, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x69, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62, 0x69, 0x67, 0x42,
0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x6c, 0x69, 0x6e, 0x64, 0x22, 0x2a, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x43, 0x72, 0x65, 0x61, 0x74,
0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x22, 0x28, 0x0a, 0x0c, 0x52, 0x65, 0x71, 0x4a, 0x6f, 0x69, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e,
0x6e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e,
0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f,
0x22, 0x0f, 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x22, 0x28, 0x0a, 0x0c, 0x52, 0x65, 0x71, 0x4a, 0x6f, 0x69, 0x6e, 0x54, 0x61, 0x62, 0x6c, 0x65,
0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x52, 0x65, 0x61, 0x64, 0x79, 0x53, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28,
0x72, 0x74, 0x22, 0x10, 0x0a, 0x0e, 0x52, 0x65, 0x71, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x05, 0x52, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x22, 0x0f, 0x0a, 0x0d, 0x52, 0x65,
0x65, 0x61, 0x64, 0x79, 0x22, 0x2d, 0x0a, 0x0f, 0x52, 0x65, 0x71, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x71, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x52,
0x75, 0x74, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x65, 0x71, 0x52, 0x65, 0x61, 0x64, 0x79, 0x53, 0x74, 0x61, 0x72, 0x74, 0x22, 0x10, 0x0a, 0x0e,
0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x52, 0x65, 0x71, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x61, 0x64, 0x79, 0x22, 0x2d,
0x72, 0x49, 0x64, 0x22, 0x11, 0x0a, 0x0f, 0x52, 0x65, 0x73, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x0a, 0x0f, 0x52, 0x65, 0x71, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x54, 0x61, 0x62, 0x6c,
0x74, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x3b, 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x47, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20,
0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x22, 0x11, 0x0a,
0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0f, 0x52, 0x65, 0x73, 0x4b, 0x69, 0x63, 0x6b, 0x4f, 0x75, 0x74, 0x54, 0x61, 0x62, 0x6c, 0x65,
0x12, 0x0a, 0x04, 0x63, 0x68, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x22, 0x3b, 0x0a, 0x0d, 0x52, 0x65, 0x71, 0x47, 0x61, 0x6d, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f,
0x68, 0x69, 0x70, 0x22, 0x0f, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x41, 0x63, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
0x74, 0x69, 0x6f, 0x6e, 0x22, 0x13, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x05, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x68, 0x69,
0x75, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x9a, 0x02, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x68, 0x69, 0x70, 0x22, 0x0f, 0x0a,
0x73, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x75, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0d, 0x52, 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x13,
0x18, 0x0a, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x75, 0x6c, 0x6c, 0x53, 0x74, 0x61,
0x52, 0x07, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x61, 0x6d, 0x74, 0x75, 0x73, 0x22, 0x9a, 0x02, 0x0a, 0x11, 0x52, 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x46,
0x65, 0x53, 0x74, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x67, 0x61, 0x75, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x61, 0x62,
0x6d, 0x65, 0x53, 0x74, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x68, 0x69, 0x70, 0x18, 0x6c, 0x65, 0x4e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x61, 0x62, 0x6c,
0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x68, 0x69, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x65, 0x4e, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x67, 0x65,
0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x67, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x67,
0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x62, 0x69, 0x67, 0x42, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x68, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52,
0x69, 0x6e, 0x64, 0x50, 0x6f, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x62, 0x69, 0x04, 0x63, 0x68, 0x69, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49,
0x67, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x73, 0x6d, 0x61, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49,
0x6c, 0x6c, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x62, 0x69, 0x67, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x73,
0x52, 0x0d, 0x73, 0x6d, 0x61, 0x6c, 0x6c, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x73, 0x12, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x62, 0x69, 0x67, 0x42, 0x6c, 0x69, 0x6e, 0x64,
0x29, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x43, 0x61, 0x72, 0x64, 0x18, 0x0e, 0x20, 0x50, 0x6f, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x73, 0x6d, 0x61, 0x6c, 0x6c, 0x42, 0x6c, 0x69, 0x6e,
0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x72, 0x64, 0x52, 0x0a, 0x64, 0x50, 0x6f, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x73, 0x6d, 0x61, 0x6c,
0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x43, 0x61, 0x72, 0x64, 0x12, 0x2a, 0x0a, 0x07, 0x70, 0x6c, 0x6c, 0x42, 0x6c, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x73, 0x12, 0x29, 0x0a, 0x0a, 0x70, 0x75, 0x62,
0x61, 0x79, 0x65, 0x72, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x6c, 0x69, 0x63, 0x43, 0x61, 0x72, 0x64, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e,
0x69, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x52, 0x07, 0x70, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x72, 0x64, 0x52, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63,
0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x22, 0x95, 0x03, 0x0a, 0x0b, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x72, 0x64, 0x12, 0x2a, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x18,
0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x54, 0x61, 0x62, 0x6c,
0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x65, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x52, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73,
0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x22, 0x95, 0x03, 0x0a, 0x0b, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72,
0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x05, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01,
0x61, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61,
0x12, 0x12, 0x0a, 0x04, 0x63, 0x68, 0x69, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61,
0x63, 0x68, 0x69, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x04, 0x20, 0x01,
0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x68,
0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x6d, 0x61, 0x69, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x68, 0x69, 0x70, 0x12, 0x16,
0x73, 0x74, 0x65, 0x72, 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x42, 0x65, 0x74, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06,
0x54, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x72, 0x6f, 0x75, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72,
0x6e, 0x64, 0x42, 0x65, 0x74, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x12, 0x24,
0x75, 0x6e, 0x64, 0x42, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0a, 0x0d, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x42, 0x65, 0x74, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x18,
0x05, 0x52, 0x0d, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x42, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x42, 0x65, 0x74, 0x54,
0x12, 0x22, 0x0a, 0x0c, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x42, 0x65, 0x74, 0x43, 0x68, 0x69, 0x70, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x42, 0x65, 0x74,
0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x42, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x72, 0x6f, 0x75,
0x43, 0x68, 0x69, 0x70, 0x12, 0x29, 0x0a, 0x08, 0x68, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x6e, 0x64, 0x42, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x74, 0x6f,
0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x48, 0x61, 0x6e, 0x74, 0x61, 0x6c, 0x42, 0x65, 0x74, 0x43, 0x68, 0x69, 0x70, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05,
0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x08, 0x68, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x52, 0x0c, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x42, 0x65, 0x74, 0x43, 0x68, 0x69, 0x70, 0x12, 0x29,
0x26, 0x0a, 0x07, 0x62, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x0a, 0x08, 0x68, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x0c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x07, 0x32, 0x0d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x48, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52,
0x62, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x25, 0x0a, 0x08, 0x68, 0x61, 0x6e, 0x64, 0x43, 0x08, 0x68, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x26, 0x0a, 0x07, 0x62, 0x65, 0x74,
0x61, 0x72, 0x64, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x61, 0x70, 0x69,
0x43, 0x61, 0x72, 0x64, 0x52, 0x08, 0x68, 0x61, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x64, 0x22, 0x2c, 0x2e, 0x42, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x07, 0x62, 0x65, 0x74, 0x52, 0x6f, 0x6c,
0x0a, 0x04, 0x43, 0x61, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x65, 0x12, 0x25, 0x0a, 0x08, 0x68, 0x61, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x64, 0x18, 0x0f, 0x20,
0x01, 0x28, 0x05, 0x52, 0x03, 0x64, 0x6f, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x75, 0x69, 0x74, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x72, 0x64, 0x52, 0x08,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x75, 0x69, 0x74, 0x22, 0x9f, 0x01, 0x0a, 0x68, 0x61, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x64, 0x22, 0x2c, 0x0a, 0x04, 0x43, 0x61, 0x72, 0x64,
0x07, 0x42, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x65, 0x74, 0x4d, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x64,
0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x65, 0x74, 0x4d, 0x69, 0x6e, 0x6f, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x75, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x12, 0x16, 0x0a, 0x06, 0x62, 0x65, 0x74, 0x4d, 0x61, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x75, 0x69, 0x74, 0x22, 0x9f, 0x01, 0x0a, 0x07, 0x42, 0x65, 0x74, 0x52, 0x6f,
0x52, 0x06, 0x62, 0x65, 0x74, 0x4d, 0x61, 0x78, 0x12, 0x22, 0x0a, 0x0c, 0x62, 0x65, 0x74, 0x54, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x65, 0x74, 0x4d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01,
0x69, 0x6d, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x28, 0x05, 0x52, 0x06, 0x62, 0x65, 0x74, 0x4d, 0x69, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x65,
0x62, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x74, 0x4d, 0x61, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x65, 0x74, 0x4d,
0x62, 0x65, 0x74, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0a, 0x61, 0x78, 0x12, 0x22, 0x0a, 0x0c, 0x62, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x4c, 0x69, 0x6d,
0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x62, 0x65, 0x74, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x4c, 0x69, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x62, 0x65, 0x74, 0x54, 0x69, 0x6d,
0x69, 0x6d, 0x69, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x65, 0x74, 0x4f, 0x70, 0x74, 0x73, 0x18, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x62, 0x65, 0x74, 0x53, 0x65, 0x63,
0x0d, 0x20, 0x03, 0x28, 0x05, 0x52, 0x07, 0x62, 0x65, 0x74, 0x4f, 0x70, 0x74, 0x73, 0x22, 0x4c, 0x6f, 0x6e, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e,
0x0a, 0x08, 0x48, 0x61, 0x6e, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x62, 0x65, 0x74, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x18,
0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x07, 0x62, 0x65, 0x74, 0x4f, 0x70, 0x74, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x05, 0x52,
0x0a, 0x06, 0x68, 0x61, 0x6e, 0x64, 0x5a, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x07, 0x62, 0x65, 0x74, 0x4f, 0x70, 0x74, 0x73, 0x22, 0x4c, 0x0a, 0x08, 0x48, 0x61, 0x6e, 0x64,
0x68, 0x61, 0x6e, 0x64, 0x5a, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01,
0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x6e, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x61, 0x6e, 0x64,
0x52, 0x65, 0x71, 0x47, 0x61, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x5a, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x61, 0x6e, 0x64, 0x5a, 0x68,
0x52, 0x65, 0x71, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x54, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52,
0x62, 0x6c, 0x65, 0x22, 0x15, 0x0a, 0x13, 0x52, 0x65, 0x73, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x05, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x65, 0x71, 0x47, 0x61, 0x6d,
0x73, 0x47, 0x61, 0x6d, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x5c, 0x0a, 0x0a, 0x52, 0x65, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x22, 0x15, 0x0a, 0x13, 0x52, 0x65, 0x71, 0x44, 0x69, 0x73,
0x71, 0x42, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x65, 0x74, 0x54, 0x6d, 0x69, 0x73, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x15, 0x0a,
0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x62, 0x65, 0x74, 0x54, 0x79, 0x13, 0x52, 0x65, 0x73, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x54,
0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x65, 0x74, 0x43, 0x68, 0x69, 0x70, 0x18, 0x02, 0x20, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x5c, 0x0a, 0x0a, 0x52, 0x65, 0x71, 0x42, 0x65, 0x74, 0x74, 0x69,
0x01, 0x28, 0x05, 0x52, 0x07, 0x62, 0x65, 0x74, 0x43, 0x68, 0x69, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20,
0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x01, 0x28, 0x05, 0x52, 0x07, 0x62, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07,
0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x73, 0x0a, 0x13, 0x52, 0x65, 0x73, 0x4e, 0x62, 0x65, 0x74, 0x43, 0x68, 0x69, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x62,
0x6f, 0x74, 0x69, 0x63, 0x65, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x65, 0x12, 0x65, 0x74, 0x43, 0x68, 0x69, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74,
0x1a, 0x0a, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74,
0x03, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x6f, 0x72, 0x22, 0x73, 0x0a, 0x13, 0x52, 0x65, 0x73, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x50,
0x69, 0x6e, 0x65, 0x31, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6c, 0x61,
0x31, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x32, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x79, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x6c, 0x61,
0x52, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x32, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x33, 0x79, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x31, 0x18, 0x0b,
0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x33, 0x22, 0x3e, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x31, 0x12, 0x14, 0x0a, 0x05, 0x6c,
0x10, 0x52, 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x45, 0x6e, 0x64, 0x53, 0x65, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x65, 0x32, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x65,
0x65, 0x12, 0x2a, 0x0a, 0x04, 0x67, 0x61, 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x33, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09,
0x16, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x75, 0x6c, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x33, 0x22, 0x3e, 0x0a, 0x10, 0x52, 0x65, 0x73, 0x47, 0x61,
0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x04, 0x67, 0x61, 0x6d, 0x65, 0x22, 0x92, 0x01, 0x6d, 0x65, 0x45, 0x6e, 0x64, 0x53, 0x65, 0x74, 0x74, 0x6c, 0x65, 0x12, 0x2a, 0x0a, 0x04, 0x67,
0x0a, 0x11, 0x52, 0x65, 0x73, 0x43, 0x61, 0x6c, 0x63, 0x57, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x43, 0x61, 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x61, 0x70, 0x69, 0x2e,
0x68, 0x69, 0x70, 0x12, 0x40, 0x0a, 0x08, 0x77, 0x69, 0x6e, 0x73, 0x43, 0x68, 0x69, 0x70, 0x18, 0x52, 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x46, 0x75, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75,
0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x43, 0x73, 0x52, 0x04, 0x67, 0x61, 0x6d, 0x65, 0x22, 0x92, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x73, 0x43,
0x61, 0x6c, 0x63, 0x57, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x43, 0x68, 0x69, 0x70, 0x2e, 0x57, 0x69, 0x61, 0x6c, 0x63, 0x57, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x43, 0x68, 0x69, 0x70, 0x12, 0x40, 0x0a,
0x6e, 0x73, 0x43, 0x68, 0x69, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x77, 0x69, 0x6e, 0x08, 0x77, 0x69, 0x6e, 0x73, 0x43, 0x68, 0x69, 0x70, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x73, 0x43, 0x68, 0x69, 0x70, 0x1a, 0x3b, 0x0a, 0x0d, 0x57, 0x69, 0x6e, 0x73, 0x43, 0x68, 0x69, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x43, 0x61, 0x6c, 0x63, 0x57, 0x69, 0x6e,
0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x6e, 0x65, 0x72, 0x43, 0x68, 0x69, 0x70, 0x2e, 0x57, 0x69, 0x6e, 0x73, 0x43, 0x68, 0x69, 0x70,
0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x77, 0x69, 0x6e, 0x73, 0x43, 0x68, 0x69, 0x70, 0x1a,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x3b, 0x0a, 0x0d, 0x57, 0x69, 0x6e, 0x73, 0x43, 0x68, 0x69, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79,
0x38, 0x01, 0x22, 0x28, 0x0a, 0x10, 0x52, 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x4e, 0x65, 0x78, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b,
0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x42, 0x0b, 0x5a, 0x09, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x28, 0x0a, 0x10,
0x2e, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x52, 0x65, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x4e, 0x65, 0x78, 0x74, 0x52, 0x6f, 0x75, 0x6e, 0x64,
0x33, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
0x05, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x22, 0x13, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x41, 0x63, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x2d, 0x0a, 0x11, 0x52,
0x65, 0x73, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65,
0x12, 0x18, 0x0a, 0x07, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x05, 0x52, 0x07, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f,
0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -2186,7 +2284,7 @@ func file_poker_proto_rawDescGZIP() []byte {
return file_poker_proto_rawDescData return file_poker_proto_rawDescData
} }
var file_poker_proto_msgTypes = make([]protoimpl.MessageInfo, 36) var file_poker_proto_msgTypes = make([]protoimpl.MessageInfo, 38)
var file_poker_proto_goTypes = []interface{}{ var file_poker_proto_goTypes = []interface{}{
(*ProtoWrap)(nil), // 0: api.ProtoWrap (*ProtoWrap)(nil), // 0: api.ProtoWrap
(*Ping)(nil), // 1: api.Ping (*Ping)(nil), // 1: api.Ping
@ -2223,7 +2321,9 @@ var file_poker_proto_goTypes = []interface{}{
(*ResGameEndSettle)(nil), // 32: api.ResGameEndSettle (*ResGameEndSettle)(nil), // 32: api.ResGameEndSettle
(*ResCalcWinnerChip)(nil), // 33: api.ResCalcWinnerChip (*ResCalcWinnerChip)(nil), // 33: api.ResCalcWinnerChip
(*ResGameNextRound)(nil), // 34: api.ResGameNextRound (*ResGameNextRound)(nil), // 34: api.ResGameNextRound
nil, // 35: api.ResCalcWinnerChip.WinsChipEntry (*ReqAccountBalance)(nil), // 35: api.ReqAccountBalance
(*ResAccountBalance)(nil), // 36: api.ResAccountBalance
nil, // 37: api.ResCalcWinnerChip.WinsChipEntry
} }
var file_poker_proto_depIdxs = []int32{ var file_poker_proto_depIdxs = []int32{
9, // 0: api.ResLobbyView.tables:type_name -> api.LobbyTable 9, // 0: api.ResLobbyView.tables:type_name -> api.LobbyTable
@ -2234,7 +2334,7 @@ var file_poker_proto_depIdxs = []int32{
25, // 5: api.TablePlayer.betRole:type_name -> api.BetRole 25, // 5: api.TablePlayer.betRole:type_name -> api.BetRole
24, // 6: api.TablePlayer.handCard:type_name -> api.Card 24, // 6: api.TablePlayer.handCard:type_name -> api.Card
22, // 7: api.ResGameEndSettle.game:type_name -> api.ResGameFullStatus 22, // 7: api.ResGameEndSettle.game:type_name -> api.ResGameFullStatus
35, // 8: api.ResCalcWinnerChip.winsChip:type_name -> api.ResCalcWinnerChip.WinsChipEntry 37, // 8: api.ResCalcWinnerChip.winsChip:type_name -> api.ResCalcWinnerChip.WinsChipEntry
9, // [9:9] is the sub-list for method output_type 9, // [9:9] is the sub-list for method output_type
9, // [9:9] is the sub-list for method input_type 9, // [9:9] is the sub-list for method input_type
9, // [9:9] is the sub-list for extension type_name 9, // [9:9] is the sub-list for extension type_name
@ -2668,6 +2768,30 @@ func file_poker_proto_init() {
return nil return nil
} }
} }
file_poker_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ReqAccountBalance); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_poker_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ResAccountBalance); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -2675,7 +2799,7 @@ func file_poker_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_poker_proto_rawDesc, RawDescriptor: file_poker_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 36, NumMessages: 38,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

9
api/poker.proto

@ -46,6 +46,7 @@ message ResIdentity {
int64 id = 3; int64 id = 3;
string username = 4; string username = 4;
string avatar = 5; string avatar = 5;
int32 balance = 6;
} }
// ============= begin // ============= begin
@ -222,3 +223,11 @@ message ResCalcWinnerChip {
message ResGameNextRound { message ResGameNextRound {
int32 round = 1; int32 round = 1;
} }
message ReqAccountBalance {
}
message ResAccountBalance {
int32 balance = 1;
}

401
api/proto.js

@ -1434,6 +1434,7 @@ export const api = $root.api = (() => {
* @property {number|Long|null} [id] ResIdentity id * @property {number|Long|null} [id] ResIdentity id
* @property {string|null} [username] ResIdentity username * @property {string|null} [username] ResIdentity username
* @property {string|null} [avatar] ResIdentity avatar * @property {string|null} [avatar] ResIdentity avatar
* @property {number|null} [balance] ResIdentity balance
*/ */
/** /**
@ -1475,6 +1476,14 @@ export const api = $root.api = (() => {
*/ */
ResIdentity.prototype.avatar = ""; ResIdentity.prototype.avatar = "";
/**
* ResIdentity balance.
* @member {number} balance
* @memberof api.ResIdentity
* @instance
*/
ResIdentity.prototype.balance = 0;
/** /**
* Creates a new ResIdentity instance using the specified properties. * Creates a new ResIdentity instance using the specified properties.
* @function create * @function create
@ -1505,6 +1514,8 @@ export const api = $root.api = (() => {
writer.uint32(/* id 4, wireType 2 =*/34).string(message.username); writer.uint32(/* id 4, wireType 2 =*/34).string(message.username);
if (message.avatar != null && Object.hasOwnProperty.call(message, "avatar")) if (message.avatar != null && Object.hasOwnProperty.call(message, "avatar"))
writer.uint32(/* id 5, wireType 2 =*/42).string(message.avatar); writer.uint32(/* id 5, wireType 2 =*/42).string(message.avatar);
if (message.balance != null && Object.hasOwnProperty.call(message, "balance"))
writer.uint32(/* id 6, wireType 0 =*/48).int32(message.balance);
return writer; return writer;
}; };
@ -1551,6 +1562,10 @@ export const api = $root.api = (() => {
message.avatar = reader.string(); message.avatar = reader.string();
break; break;
} }
case 6: {
message.balance = reader.int32();
break;
}
default: default:
reader.skipType(tag & 7); reader.skipType(tag & 7);
break; break;
@ -1595,6 +1610,9 @@ export const api = $root.api = (() => {
if (message.avatar != null && message.hasOwnProperty("avatar")) if (message.avatar != null && message.hasOwnProperty("avatar"))
if (!$util.isString(message.avatar)) if (!$util.isString(message.avatar))
return "avatar: string expected"; return "avatar: string expected";
if (message.balance != null && message.hasOwnProperty("balance"))
if (!$util.isInteger(message.balance))
return "balance: integer expected";
return null; return null;
}; };
@ -1623,6 +1641,8 @@ export const api = $root.api = (() => {
message.username = String(object.username); message.username = String(object.username);
if (object.avatar != null) if (object.avatar != null)
message.avatar = String(object.avatar); message.avatar = String(object.avatar);
if (object.balance != null)
message.balance = object.balance | 0;
return message; return message;
}; };
@ -1647,6 +1667,7 @@ export const api = $root.api = (() => {
object.id = options.longs === String ? "0" : 0; object.id = options.longs === String ? "0" : 0;
object.username = ""; object.username = "";
object.avatar = ""; object.avatar = "";
object.balance = 0;
} }
if (message.id != null && message.hasOwnProperty("id")) if (message.id != null && message.hasOwnProperty("id"))
if (typeof message.id === "number") if (typeof message.id === "number")
@ -1657,6 +1678,8 @@ export const api = $root.api = (() => {
object.username = message.username; object.username = message.username;
if (message.avatar != null && message.hasOwnProperty("avatar")) if (message.avatar != null && message.hasOwnProperty("avatar"))
object.avatar = message.avatar; object.avatar = message.avatar;
if (message.balance != null && message.hasOwnProperty("balance"))
object.balance = message.balance;
return object; return object;
}; };
@ -8356,6 +8379,384 @@ export const api = $root.api = (() => {
return ResGameNextRound; return ResGameNextRound;
})(); })();
api.ReqAccountBalance = (function() {
/**
* Properties of a ReqAccountBalance.
* @memberof api
* @interface IReqAccountBalance
*/
/**
* Constructs a new ReqAccountBalance.
* @memberof api
* @classdesc Represents a ReqAccountBalance.
* @implements IReqAccountBalance
* @constructor
* @param {api.IReqAccountBalance=} [properties] Properties to set
*/
function ReqAccountBalance(properties) {
if (properties)
for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* Creates a new ReqAccountBalance instance using the specified properties.
* @function create
* @memberof api.ReqAccountBalance
* @static
* @param {api.IReqAccountBalance=} [properties] Properties to set
* @returns {api.ReqAccountBalance} ReqAccountBalance instance
*/
ReqAccountBalance.create = function create(properties) {
return new ReqAccountBalance(properties);
};
/**
* Encodes the specified ReqAccountBalance message. Does not implicitly {@link api.ReqAccountBalance.verify|verify} messages.
* @function encode
* @memberof api.ReqAccountBalance
* @static
* @param {api.IReqAccountBalance} message ReqAccountBalance message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
ReqAccountBalance.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
return writer;
};
/**
* Encodes the specified ReqAccountBalance message, length delimited. Does not implicitly {@link api.ReqAccountBalance.verify|verify} messages.
* @function encodeDelimited
* @memberof api.ReqAccountBalance
* @static
* @param {api.IReqAccountBalance} message ReqAccountBalance message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
ReqAccountBalance.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a ReqAccountBalance message from the specified reader or buffer.
* @function decode
* @memberof api.ReqAccountBalance
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {api.ReqAccountBalance} ReqAccountBalance
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
ReqAccountBalance.decode = function decode(reader, length) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ReqAccountBalance();
while (reader.pos < end) {
let tag = reader.uint32();
switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a ReqAccountBalance message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof api.ReqAccountBalance
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {api.ReqAccountBalance} ReqAccountBalance
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
ReqAccountBalance.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a ReqAccountBalance message.
* @function verify
* @memberof api.ReqAccountBalance
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
ReqAccountBalance.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
return null;
};
/**
* Creates a ReqAccountBalance message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof api.ReqAccountBalance
* @static
* @param {Object.<string,*>} object Plain object
* @returns {api.ReqAccountBalance} ReqAccountBalance
*/
ReqAccountBalance.fromObject = function fromObject(object) {
if (object instanceof $root.api.ReqAccountBalance)
return object;
return new $root.api.ReqAccountBalance();
};
/**
* Creates a plain object from a ReqAccountBalance message. Also converts values to other types if specified.
* @function toObject
* @memberof api.ReqAccountBalance
* @static
* @param {api.ReqAccountBalance} message ReqAccountBalance
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
ReqAccountBalance.toObject = function toObject() {
return {};
};
/**
* Converts this ReqAccountBalance to JSON.
* @function toJSON
* @memberof api.ReqAccountBalance
* @instance
* @returns {Object.<string,*>} JSON object
*/
ReqAccountBalance.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for ReqAccountBalance
* @function getTypeUrl
* @memberof api.ReqAccountBalance
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
ReqAccountBalance.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/api.ReqAccountBalance";
};
return ReqAccountBalance;
})();
api.ResAccountBalance = (function() {
/**
* Properties of a ResAccountBalance.
* @memberof api
* @interface IResAccountBalance
* @property {number|null} [balance] ResAccountBalance balance
*/
/**
* Constructs a new ResAccountBalance.
* @memberof api
* @classdesc Represents a ResAccountBalance.
* @implements IResAccountBalance
* @constructor
* @param {api.IResAccountBalance=} [properties] Properties to set
*/
function ResAccountBalance(properties) {
if (properties)
for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* ResAccountBalance balance.
* @member {number} balance
* @memberof api.ResAccountBalance
* @instance
*/
ResAccountBalance.prototype.balance = 0;
/**
* Creates a new ResAccountBalance instance using the specified properties.
* @function create
* @memberof api.ResAccountBalance
* @static
* @param {api.IResAccountBalance=} [properties] Properties to set
* @returns {api.ResAccountBalance} ResAccountBalance instance
*/
ResAccountBalance.create = function create(properties) {
return new ResAccountBalance(properties);
};
/**
* Encodes the specified ResAccountBalance message. Does not implicitly {@link api.ResAccountBalance.verify|verify} messages.
* @function encode
* @memberof api.ResAccountBalance
* @static
* @param {api.IResAccountBalance} message ResAccountBalance message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
ResAccountBalance.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.balance != null && Object.hasOwnProperty.call(message, "balance"))
writer.uint32(/* id 1, wireType 0 =*/8).int32(message.balance);
return writer;
};
/**
* Encodes the specified ResAccountBalance message, length delimited. Does not implicitly {@link api.ResAccountBalance.verify|verify} messages.
* @function encodeDelimited
* @memberof api.ResAccountBalance
* @static
* @param {api.IResAccountBalance} message ResAccountBalance message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
ResAccountBalance.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a ResAccountBalance message from the specified reader or buffer.
* @function decode
* @memberof api.ResAccountBalance
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {api.ResAccountBalance} ResAccountBalance
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
ResAccountBalance.decode = function decode(reader, length) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ResAccountBalance();
while (reader.pos < end) {
let tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
message.balance = reader.int32();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a ResAccountBalance message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof api.ResAccountBalance
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {api.ResAccountBalance} ResAccountBalance
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
ResAccountBalance.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a ResAccountBalance message.
* @function verify
* @memberof api.ResAccountBalance
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
ResAccountBalance.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.balance != null && message.hasOwnProperty("balance"))
if (!$util.isInteger(message.balance))
return "balance: integer expected";
return null;
};
/**
* Creates a ResAccountBalance message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof api.ResAccountBalance
* @static
* @param {Object.<string,*>} object Plain object
* @returns {api.ResAccountBalance} ResAccountBalance
*/
ResAccountBalance.fromObject = function fromObject(object) {
if (object instanceof $root.api.ResAccountBalance)
return object;
let message = new $root.api.ResAccountBalance();
if (object.balance != null)
message.balance = object.balance | 0;
return message;
};
/**
* Creates a plain object from a ResAccountBalance message. Also converts values to other types if specified.
* @function toObject
* @memberof api.ResAccountBalance
* @static
* @param {api.ResAccountBalance} message ResAccountBalance
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
ResAccountBalance.toObject = function toObject(message, options) {
if (!options)
options = {};
let object = {};
if (options.defaults)
object.balance = 0;
if (message.balance != null && message.hasOwnProperty("balance"))
object.balance = message.balance;
return object;
};
/**
* Converts this ResAccountBalance to JSON.
* @function toJSON
* @memberof api.ResAccountBalance
* @instance
* @returns {Object.<string,*>} JSON object
*/
ResAccountBalance.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for ResAccountBalance
* @function getTypeUrl
* @memberof api.ResAccountBalance
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
ResAccountBalance.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/api.ResAccountBalance";
};
return ResAccountBalance;
})();
return api; return api;
})(); })();

2
internal/game/actions.go

@ -273,7 +273,7 @@ func SetNextPlayer4Limited(roundStart bool, t *Table, current *Player) {
if nextP.BetMax > nextP.BetMin { // 加注 if nextP.BetMax > nextP.BetMin { // 加注
nextP.BetOpts = append(nextP.BetOpts, 2) nextP.BetOpts = append(nextP.BetOpts, 2)
} }
// TODO 下注倒计时 // 下注倒计时
nextP.BetTimeLimit = time.Now().Add(120 * time.Second) nextP.BetTimeLimit = time.Now().Add(120 * time.Second)
nextP.AutoBetDelayCanceler = nextP.GameTable.RefAutoBettingDelayQueue.Delay(120*time.Second, nextP.Id) nextP.AutoBetDelayCanceler = nextP.GameTable.RefAutoBettingDelayQueue.Delay(120*time.Second, nextP.Id)

12
internal/logic/account.go

@ -0,0 +1,12 @@
package logic
import (
"github.com/golang/protobuf/proto"
"texas-poker-bk/api"
"texas-poker-bk/internal/session"
)
// HandleReqAccountBalance 返回账户余额
func HandleReqAccountBalance(account *session.NetAccount, msg *api.ReqAccountBalance) (proto.Message, error) {
return &api.ResAccountBalance{Balance: account.Balance}, nil
}

53
internal/logic/auth.go

@ -227,39 +227,44 @@ func HandleReqIdentity(client *session.NetClient, msg *api.ReqIdentity) (proto.M
if subject.TokenVersion != store.TokenVersions.Get(subject.Id) { if subject.TokenVersion != store.TokenVersions.Get(subject.Id) {
return &api.ResFail{Code: 401, Msg: "登录已过期"}, nil return &api.ResFail{Code: 401, Msg: "登录已过期"}, nil
} }
dbUser := &entity.User{Id: subject.Id}
account := &session.NetAccount{ row := dao.UserDao.DB.First(dbUser).RowsAffected
Id: subject.Id, if row == 0 {
UserName: subject.Name, return &api.ResFail{Code: 401, Msg: "账户不存在"}, nil
Avatar: subject.Avatar,
Client: client,
Balance: 1000,
BalanceLock: &sync.RWMutex{},
Lock: &sync.Mutex{},
} }
// TODO 查询 DB 账户余额,处理断线、重连问题 account := store.NetAccounts.Get(subject.Id)
current := store.NetAccounts.Get(account.Id) if account == nil {
if current == nil { // 查询DB 账户情况
account = &session.NetAccount{
Id: subject.Id,
UserName: dbUser.Username,
Avatar: dbUser.Avatar,
Balance: dbUser.Balance,
Client: client,
BalanceLock: &sync.RWMutex{},
Lock: &sync.Mutex{},
}
store.NetAccounts.SetDefault(account.Id, account) store.NetAccounts.SetDefault(account.Id, account)
} else { } else {
// 掉线重连的用户, TODO 重复登录的用户 // 掉线重连的用户, 重复登录的用户
current.Client.Write(&api.ResFail{Code: 403, Msg: "该账号在其他地方登录,您已下线"}) account.Client.Write(&api.ResFail{Code: 403, Msg: "该账号在其他地方登录,您已下线"})
current.Client = account.Client account.Client = client
if current.Player != nil { if account.Player != nil {
current.Player.Client = account.Client account.Player.Client = client
} }
account = current
} }
client.Account = account client.Account = account
// 在线通知消息 // 在线通知消息
event.OnlineWatcher.Publish(account.Id, true) event.OnlineWatcher.Publish(subject.Id, true)
// response // response
res := &api.ResIdentity{Id: subject.Id, Username: subject.Name, Avatar: subject.Avatar} res := &api.ResIdentity{
Id: subject.Id,
Username: account.UserName,
Avatar: account.Avatar,
Balance: account.Balance,
}
return res, nil return res, nil
} }
func scheduleAccountPing() {
}

94
internal/logic/balance/balance.go

@ -0,0 +1,94 @@
package balance
import (
"github.com/emirpasic/gods/maps/treemap"
"sync"
"sync/atomic"
"texas-poker-bk/internal/dao"
"texas-poker-bk/internal/model/entity"
"texas-poker-bk/tool/async"
)
var (
AsyncPersist *balancePersist
)
func init() {
AsyncPersist = &balancePersist{}
AsyncPersist.init()
}
// balancePersist 账户金额持久化
// TODO Persist() 先写log文件后return, 宕机后从log文件恢复
type balancePersist struct {
// 待持久化用户id列表
// idQueue []int32
consuming *atomic.Bool
counter *atomic.Int64
idQueue *treemap.Map
// accountBalance 存储账户最新金额
//accountBalance *cache.Cache
balanceMap map[int64]int32
executor *async.ConcurrentLimiter
lock *sync.RWMutex
}
func (b *balancePersist) init() {
b.consuming = &atomic.Bool{}
b.counter = &atomic.Int64{}
b.idQueue = treemap.NewWithIntComparator()
//b.accountBalance = cache.New(cache.DefaultExpiration, cache.DefaultExpiration)
b.balanceMap = make(map[int64]int32, 64)
b.executor = async.NewConcurrentLimiter(8, 32)
b.lock = &sync.RWMutex{}
}
func (b *balancePersist) goConsumer() {
if !b.consuming.CompareAndSwap(false, true) {
return
}
go func() {
for {
accountId, balance := b.next()
if accountId == -1 {
b.consuming.Store(false)
return
}
b.executor.Run(func() {
dao.UserDao.DB.Model(&entity.User{}).
Where("id = ?", accountId).
Update("balance", balance)
})
}
}()
}
func (b *balancePersist) Persist(accountId int64, balance int32) {
defer b.goConsumer()
b.lock.Lock()
defer b.lock.Unlock()
b.idQueue.Put(int(b.counter.Add(1)), accountId)
b.balanceMap[accountId] = balance
}
func (b *balancePersist) next() (int64, int32) {
b.lock.Lock()
defer b.lock.Unlock()
k, id := b.idQueue.Min()
if k == 0 || k == nil {
return -1, -1
}
accountId, ok := id.(int64)
if !ok {
return -1, -1
}
balance, ok := b.balanceMap[accountId]
if !ok {
return -1, -1
}
b.idQueue.Remove(k)
delete(b.balanceMap, accountId)
return accountId, balance
}

8
internal/logic/delayer/offline.go

@ -30,9 +30,11 @@ func handleOfflineDelay(accountId int64, now time.Time) {
} }
// 牌局未在进行中直接移除玩家并下线 // 牌局未在进行中直接移除玩家并下线
if collect.In(account.Player.GameTable.Stage, 1, 9) { if collect.In(account.Player.GameTable.Stage, 1, 9) {
found, _ := account.Player.GameTable.RemovePlayer(account.Id) table := account.Player.GameTable
found, _ := table.RemovePlayer(account.Id)
if found { if found {
account.SettlePlayerChip() account.SettlePlayerChip()
table.NoticeGameFullStatus()
} }
removeMemoryAccount(accountId) removeMemoryAccount(accountId)
return return
@ -46,9 +48,11 @@ func handleOfflineDelay(accountId int64, now time.Time) {
return return
} }
// 从牌桌移除玩家 // 从牌桌移除玩家
found, _ := account.Player.GameTable.RemovePlayer(account.Id) table := account.Player.GameTable
found, _ := table.RemovePlayer(account.Id)
if found { if found {
account.SettlePlayerChip() account.SettlePlayerChip()
table.NoticeGameFullStatus()
} }
removeMemoryAccount(account.Id) removeMemoryAccount(account.Id)
}) })

10
internal/server/ws.go

@ -7,6 +7,7 @@ import (
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"log" "log"
"net/http" "net/http"
"runtime/debug"
"texas-poker-bk/api" "texas-poker-bk/api"
"texas-poker-bk/internal/conf" "texas-poker-bk/internal/conf"
"texas-poker-bk/internal/logic/event" "texas-poker-bk/internal/logic/event"
@ -79,6 +80,8 @@ func handleNetClient(client *session.NetClient) {
// 捕获其他错误 // 捕获其他错误
if r := recover(); r != nil { if r := recover(); r != nil {
fmt.Println("recover error: ", r) fmt.Println("recover error: ", r)
// 输出堆栈信息
fmt.Println(string(debug.Stack()))
client.Write(&api.ResFail{Code: 500, Msg: r.(error).Error()}) client.Write(&api.ResFail{Code: 500, Msg: r.(error).Error()})
} }
}() }()
@ -136,7 +139,12 @@ func handleNetClient(client *session.NetClient) {
client.Close("api body unmarshal fail! " + err.Error()) client.Close("api body unmarshal fail! " + err.Error())
return return
} }
log.Println(fmt.Sprintf("ws msg: %T{%v}", msg, msg))
switch msg.(type) {
case *api.Ping:
default:
log.Println(fmt.Sprintf("ws msg: %T{%v}", msg, msg))
}
// TODO queue channel -> msg -> handler // TODO queue channel -> msg -> handler
var called bool var called bool

2
internal/server/wsroute.go

@ -43,6 +43,8 @@ func init() {
HandleNetPlayerMsg(&api.ReqGameStart{}, logic.HandleReqGameStart) HandleNetPlayerMsg(&api.ReqGameStart{}, logic.HandleReqGameStart)
// 筹码下注 // 筹码下注
HandleNetPlayerMsg(&api.ReqBetting{}, logic.HandleReqBetting) HandleNetPlayerMsg(&api.ReqBetting{}, logic.HandleReqBetting)
// 查看账户余额
HandleNetAccountMsg(&api.ReqAccountBalance{}, logic.HandleReqAccountBalance)
} }
func checkExistsTypeHandler(op int32, err error) { func checkExistsTypeHandler(op int32, err error) {

10
internal/session/net_account.go

@ -3,6 +3,7 @@ package session
import ( import (
"sync" "sync"
"texas-poker-bk/internal/game" "texas-poker-bk/internal/game"
"texas-poker-bk/internal/logic/balance"
"texas-poker-bk/tool/async" "texas-poker-bk/tool/async"
) )
@ -24,7 +25,9 @@ func (account *NetAccount) DecrementBalance(amount int32) int32 {
account.BalanceLock.Lock() account.BalanceLock.Lock()
defer account.BalanceLock.Unlock() defer account.BalanceLock.Unlock()
account.Balance -= amount account.Balance -= amount
// TODO 同步到 DB
// 账户金额持久化
balance.AsyncPersist.Persist(account.Id, account.Balance)
return account.Balance return account.Balance
} }
@ -32,6 +35,9 @@ func (account *NetAccount) IncrementBalance(amount int32) int32 {
account.BalanceLock.Lock() account.BalanceLock.Lock()
defer account.BalanceLock.Unlock() defer account.BalanceLock.Unlock()
account.Balance += amount account.Balance += amount
// 账户金额持久化
balance.AsyncPersist.Persist(account.Id, account.Balance)
return account.Balance return account.Balance
} }
@ -43,7 +49,7 @@ func (account *NetAccount) GetBalance() int32 {
func (account *NetAccount) SettlePlayerChip() { func (account *NetAccount) SettlePlayerChip() {
// 返还玩家账户金额 // 返还玩家账户金额
account.IncrementBalance(account.Player.Chip) // 牌桌筹码返还到账户 TODO 持久化 account.IncrementBalance(account.Player.Chip) // 牌桌筹码返还到账户
account.Player.Chip = 0 account.Player.Chip = 0
account.Player = nil // 解除账户绑定 account.Player = nil // 解除账户绑定
} }

60
tool/async/concurrent_limiter.go

@ -0,0 +1,60 @@
package async
import (
"fmt"
"runtime/debug"
)
type ConcurrentLimiter struct {
concurrent int
buffer chan func()
stop chan bool
}
func NewConcurrentLimiter(concurrent int, buffer int) *ConcurrentLimiter {
limiter := &ConcurrentLimiter{
concurrent: concurrent,
buffer: make(chan func(), buffer),
stop: make(chan bool, concurrent),
}
limiter.init()
return limiter
}
func (c *ConcurrentLimiter) init() {
// 起 n 个 goroutine 循环监测 task chan
for i := 0; i < c.concurrent; i++ {
go func() {
for {
select {
case task := <-c.buffer:
func() {
defer func() {
if err := recover(); err != nil {
fmt.Printf("consumer handler error: %v \n", err)
// 输出堆栈信息
fmt.Println(string(debug.Stack()))
}
}()
// 执行任务
task()
}()
// 停止执行
case <-c.stop:
return
}
}
}()
}
}
func (c *ConcurrentLimiter) Run(f func()) {
c.buffer <- f
}
func (c *ConcurrentLimiter) StopAll() chan func() {
for i := 0; i < c.concurrent; i++ {
c.stop <- true
}
return c.buffer
}

4
tool/async/delay_queue.go

@ -36,7 +36,7 @@ const (
// DelayQueue key: int64(64bit) = 1(0固定值)+41(ms)+22(index) // DelayQueue key: int64(64bit) = 1(0固定值)+41(ms)+22(index)
type DelayQueue[T any] struct { type DelayQueue[T any] struct {
taskQueueMap *treemap.Map taskQueueMap *treemap.Map
lock *sync.RWMutex lock *sync.Mutex
offsetMs int64 offsetMs int64
checkInterval time.Duration checkInterval time.Duration
handler func(data T, now time.Time) (nextData T) // nextData用作scheduler下次执行时参数 handler func(data T, now time.Time) (nextData T) // nextData用作scheduler下次执行时参数
@ -47,7 +47,7 @@ type DelayQueue[T any] struct {
func NewDelayQueue[T any](checkInterval time.Duration, buffer int, handler func(T, time.Time)) *DelayQueue[T] { func NewDelayQueue[T any](checkInterval time.Duration, buffer int, handler func(T, time.Time)) *DelayQueue[T] {
q := &DelayQueue[T]{} q := &DelayQueue[T]{}
q.taskQueueMap = treemap.NewWithIntComparator() q.taskQueueMap = treemap.NewWithIntComparator()
q.lock = &sync.RWMutex{} q.lock = &sync.Mutex{}
q.offsetMs = time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC).UnixMilli() q.offsetMs = time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC).UnixMilli()
q.checkInterval = checkInterval q.checkInterval = checkInterval
q.handler = func(data T, now time.Time) (zero T) { q.handler = func(data T, now time.Time) (zero T) {

Loading…
Cancel
Save