From 6eb14c139e16e53d33b1d340e1388ab8557cd767 Mon Sep 17 00:00:00 2001 From: tangmingyou <234767776@qq.com> Date: Fri, 13 Jan 2023 11:39:25 +0800 Subject: [PATCH] ws res msg process --- api/generate.go | 2 +- api/operation.go | 19 +- api/poker.pb.go | 443 +++++++++- api/poker.proto | 32 +- api/proto.js | 1495 +++++++++++++++++++++++++++++++- cmd/main.go | 1 - internal/server/server.go | 2 +- internal/server/ws.go | 20 +- internal/server/wsroute.go | 4 +- internal/session/net_client.go | 6 +- 10 files changed, 1972 insertions(+), 52 deletions(-) diff --git a/api/generate.go b/api/generate.go index 6761678..9d8efd6 100644 --- a/api/generate.go +++ b/api/generate.go @@ -1,6 +1,6 @@ package api ////go:generate protoc -I. -I$GOPATH/src --go_out=plugins=grpc:. --go_opt=paths=source_relative protocol/protocol.proto -//go:generate protoc --go_out=./ --go_opt=paths=source_relative poker.proto +//go:generate protoc --go_out=./ --go_opt=paths=source_relative *.proto //go:generate pbjs -t static-module -w es6 -o proto.js *.proto diff --git a/api/operation.go b/api/operation.go index 72b9a0f..9c1c26a 100644 --- a/api/operation.go +++ b/api/operation.go @@ -13,16 +13,23 @@ const OpOffset int32 = 13578 // 注册消息类型 var protoInstances = []proto.Message{ &ProtoWrap{}, + &ResFail{}, &Ping{}, &Pong{}, &ReqIdentity{}, &ResIdentity{}, + &ReqLobbyView{}, + &ResLobbyView{}, + &ReqCreateTable{}, + &ReqJoinTable{}, + &ResJoinTable{}, } var ( prototypeOpMap = make(map[reflect.Type]int32) opPrototypeMap = make(map[int32]reflect.Type) // TODO array opProtoNameMap = make(map[int32][2]string) + protoNameOpMap = make(map[string]int32) // opInstanceMap = make(map[int]any) ) @@ -41,6 +48,7 @@ func init() { } name := t.Elem().Name() opProtoNameMap[op+OpOffset] = [2]string{pkg, name} + protoNameOpMap[pkg+"."+name] = op + OpOffset } } @@ -63,6 +71,13 @@ func NewProtoInstance(op int32) (proto.Message, error) { } // GetOpNameMap 获取编号和消息 -func GetOpNameMap() map[int32][2]string { - return opProtoNameMap +func GetOpNameMap() map[string]any { + failOp, _ := GetProtoOp(&ResFail{}) + front := make(map[string]any, 4) + + front["offset"] = OpOffset + front["failOp"] = failOp + front["opPathMap"] = opProtoNameMap + front["nameOpMap"] = protoNameOpMap + return front } diff --git a/api/poker.pb.go b/api/poker.pb.go index 5e2a9dc..73e4345 100644 --- a/api/poker.pb.go +++ b/api/poker.pb.go @@ -27,10 +27,11 @@ type ProtoWrap struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Ver int32 `protobuf:"varint,1,opt,name=ver,proto3" json:"ver,omitempty"` // version - Op int32 `protobuf:"varint,2,opt,name=op,proto3" json:"op,omitempty"` // option/action - Seq int32 `protobuf:"varint,3,opt,name=seq,proto3" json:"seq,omitempty"` // sequence - Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"` // proto bytes + Ver int32 `protobuf:"varint,1,opt,name=ver,proto3" json:"ver,omitempty"` // version + Op int32 `protobuf:"varint,2,opt,name=op,proto3" json:"op,omitempty"` // option/action + Seq int32 `protobuf:"varint,3,opt,name=seq,proto3" json:"seq,omitempty"` // sequence + Success bool `protobuf:"varint,4,opt,name=success,proto3" json:"success,omitempty"` // 请求是否成功 + Body []byte `protobuf:"bytes,7,opt,name=body,proto3" json:"body,omitempty"` // proto bytes } func (x *ProtoWrap) Reset() { @@ -86,6 +87,13 @@ func (x *ProtoWrap) GetSeq() int32 { return 0 } +func (x *ProtoWrap) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + func (x *ProtoWrap) GetBody() []byte { if x != nil { return x.Body @@ -169,6 +177,54 @@ func (*Pong) Descriptor() ([]byte, []int) { return file_poker_proto_rawDescGZIP(), []int{2} } +// 失败响应 +type ResFail struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Msg string `protobuf:"bytes,3,opt,name=msg,proto3" json:"msg,omitempty"` // 失败消息 +} + +func (x *ResFail) Reset() { + *x = ResFail{} + if protoimpl.UnsafeEnabled { + mi := &file_poker_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResFail) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResFail) ProtoMessage() {} + +func (x *ResFail) ProtoReflect() protoreflect.Message { + mi := &file_poker_proto_msgTypes[3] + 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 ResFail.ProtoReflect.Descriptor instead. +func (*ResFail) Descriptor() ([]byte, []int) { + return file_poker_proto_rawDescGZIP(), []int{3} +} + +func (x *ResFail) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + type ReqIdentity struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -180,7 +236,7 @@ type ReqIdentity struct { func (x *ReqIdentity) Reset() { *x = ReqIdentity{} if protoimpl.UnsafeEnabled { - mi := &file_poker_proto_msgTypes[3] + mi := &file_poker_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -193,7 +249,7 @@ func (x *ReqIdentity) String() string { func (*ReqIdentity) ProtoMessage() {} func (x *ReqIdentity) ProtoReflect() protoreflect.Message { - mi := &file_poker_proto_msgTypes[3] + mi := &file_poker_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -206,7 +262,7 @@ func (x *ReqIdentity) ProtoReflect() protoreflect.Message { // Deprecated: Use ReqIdentity.ProtoReflect.Descriptor instead. func (*ReqIdentity) Descriptor() ([]byte, []int) { - return file_poker_proto_rawDescGZIP(), []int{3} + return file_poker_proto_rawDescGZIP(), []int{4} } func (x *ReqIdentity) GetToken() string { @@ -228,7 +284,7 @@ type ResIdentity struct { func (x *ResIdentity) Reset() { *x = ResIdentity{} if protoimpl.UnsafeEnabled { - mi := &file_poker_proto_msgTypes[4] + mi := &file_poker_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -241,7 +297,7 @@ func (x *ResIdentity) String() string { func (*ResIdentity) ProtoMessage() {} func (x *ResIdentity) ProtoReflect() protoreflect.Message { - mi := &file_poker_proto_msgTypes[4] + mi := &file_poker_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -254,7 +310,7 @@ func (x *ResIdentity) ProtoReflect() protoreflect.Message { // Deprecated: Use ResIdentity.ProtoReflect.Descriptor instead. func (*ResIdentity) Descriptor() ([]byte, []int) { - return file_poker_proto_rawDescGZIP(), []int{4} + return file_poker_proto_rawDescGZIP(), []int{5} } func (x *ResIdentity) GetStatus() int32 { @@ -271,24 +327,262 @@ func (x *ResIdentity) GetMsg() string { return "" } +type ReqLobbyView struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ReqLobbyView) Reset() { + *x = ReqLobbyView{} + if protoimpl.UnsafeEnabled { + mi := &file_poker_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReqLobbyView) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReqLobbyView) ProtoMessage() {} + +func (x *ReqLobbyView) ProtoReflect() protoreflect.Message { + mi := &file_poker_proto_msgTypes[6] + 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 ReqLobbyView.ProtoReflect.Descriptor instead. +func (*ReqLobbyView) Descriptor() ([]byte, []int) { + return file_poker_proto_rawDescGZIP(), []int{6} +} + +type ResLobbyView struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ResLobbyView) Reset() { + *x = ResLobbyView{} + if protoimpl.UnsafeEnabled { + mi := &file_poker_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResLobbyView) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResLobbyView) ProtoMessage() {} + +func (x *ResLobbyView) ProtoReflect() protoreflect.Message { + mi := &file_poker_proto_msgTypes[7] + 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 ResLobbyView.ProtoReflect.Descriptor instead. +func (*ResLobbyView) Descriptor() ([]byte, []int) { + return file_poker_proto_rawDescGZIP(), []int{7} +} + +type ReqCreateTable struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ReqCreateTable) Reset() { + *x = ReqCreateTable{} + if protoimpl.UnsafeEnabled { + mi := &file_poker_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReqCreateTable) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReqCreateTable) ProtoMessage() {} + +func (x *ReqCreateTable) ProtoReflect() protoreflect.Message { + mi := &file_poker_proto_msgTypes[8] + 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 ReqCreateTable.ProtoReflect.Descriptor instead. +func (*ReqCreateTable) Descriptor() ([]byte, []int) { + return file_poker_proto_rawDescGZIP(), []int{8} +} + +type ResCreateTable struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ResCreateTable) Reset() { + *x = ResCreateTable{} + if protoimpl.UnsafeEnabled { + mi := &file_poker_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResCreateTable) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResCreateTable) ProtoMessage() {} + +func (x *ResCreateTable) ProtoReflect() protoreflect.Message { + mi := &file_poker_proto_msgTypes[9] + 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 ResCreateTable.ProtoReflect.Descriptor instead. +func (*ResCreateTable) Descriptor() ([]byte, []int) { + return file_poker_proto_rawDescGZIP(), []int{9} +} + +type ReqJoinTable struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ReqJoinTable) Reset() { + *x = ReqJoinTable{} + if protoimpl.UnsafeEnabled { + mi := &file_poker_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReqJoinTable) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReqJoinTable) ProtoMessage() {} + +func (x *ReqJoinTable) ProtoReflect() protoreflect.Message { + mi := &file_poker_proto_msgTypes[10] + 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 ReqJoinTable.ProtoReflect.Descriptor instead. +func (*ReqJoinTable) Descriptor() ([]byte, []int) { + return file_poker_proto_rawDescGZIP(), []int{10} +} + +type ResJoinTable struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ResJoinTable) Reset() { + *x = ResJoinTable{} + if protoimpl.UnsafeEnabled { + mi := &file_poker_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResJoinTable) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResJoinTable) ProtoMessage() {} + +func (x *ResJoinTable) ProtoReflect() protoreflect.Message { + mi := &file_poker_proto_msgTypes[11] + 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 ResJoinTable.ProtoReflect.Descriptor instead. +func (*ResJoinTable) Descriptor() ([]byte, []int) { + return file_poker_proto_rawDescGZIP(), []int{11} +} + var File_poker_proto protoreflect.FileDescriptor var file_poker_proto_rawDesc = []byte{ 0x0a, 0x0b, 0x70, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, - 0x70, 0x69, 0x22, 0x53, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x57, 0x72, 0x61, 0x70, 0x12, + 0x70, 0x69, 0x22, 0x6d, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x57, 0x72, 0x61, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6f, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x71, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, - 0x73, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x06, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x22, - 0x06, 0x0a, 0x04, 0x50, 0x6f, 0x6e, 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, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x37, 0x0a, 0x0b, - 0x52, 0x65, 0x73, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x6d, 0x73, 0x67, 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, - 0x70, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, + 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, + 0x79, 0x22, 0x06, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x22, 0x06, 0x0a, 0x04, 0x50, 0x6f, 0x6e, + 0x67, 0x22, 0x1b, 0x0a, 0x07, 0x52, 0x65, 0x73, 0x46, 0x61, 0x69, 0x6c, 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, 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, 0x37, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, + 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x0e, 0x0a, 0x0c, + 0x52, 0x65, 0x71, 0x4c, 0x6f, 0x62, 0x62, 0x79, 0x56, 0x69, 0x65, 0x77, 0x22, 0x0e, 0x0a, 0x0c, + 0x52, 0x65, 0x73, 0x4c, 0x6f, 0x62, 0x62, 0x79, 0x56, 0x69, 0x65, 0x77, 0x22, 0x10, 0x0a, 0x0e, + 0x52, 0x65, 0x71, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x22, 0x10, + 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, + 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x65, 0x71, 0x4a, 0x6f, 0x69, 0x6e, 0x54, 0x61, 0x62, 0x6c, 0x65, + 0x22, 0x0e, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x4a, 0x6f, 0x69, 0x6e, 0x54, 0x61, 0x62, 0x6c, 0x65, + 0x42, 0x0b, 0x5a, 0x09, 0x2e, 0x2f, 0x61, 0x70, 0x69, 0x3b, 0x61, 0x70, 0x69, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -303,13 +597,20 @@ func file_poker_proto_rawDescGZIP() []byte { return file_poker_proto_rawDescData } -var file_poker_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_poker_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_poker_proto_goTypes = []interface{}{ - (*ProtoWrap)(nil), // 0: api.ProtoWrap - (*Ping)(nil), // 1: api.Ping - (*Pong)(nil), // 2: api.Pong - (*ReqIdentity)(nil), // 3: api.ReqIdentity - (*ResIdentity)(nil), // 4: api.ResIdentity + (*ProtoWrap)(nil), // 0: api.ProtoWrap + (*Ping)(nil), // 1: api.Ping + (*Pong)(nil), // 2: api.Pong + (*ResFail)(nil), // 3: api.ResFail + (*ReqIdentity)(nil), // 4: api.ReqIdentity + (*ResIdentity)(nil), // 5: api.ResIdentity + (*ReqLobbyView)(nil), // 6: api.ReqLobbyView + (*ResLobbyView)(nil), // 7: api.ResLobbyView + (*ReqCreateTable)(nil), // 8: api.ReqCreateTable + (*ResCreateTable)(nil), // 9: api.ResCreateTable + (*ReqJoinTable)(nil), // 10: api.ReqJoinTable + (*ResJoinTable)(nil), // 11: api.ResJoinTable } var file_poker_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type @@ -362,7 +663,7 @@ func file_poker_proto_init() { } } file_poker_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReqIdentity); i { + switch v := v.(*ResFail); i { case 0: return &v.state case 1: @@ -374,6 +675,18 @@ func file_poker_proto_init() { } } file_poker_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReqIdentity); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poker_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ResIdentity); i { case 0: return &v.state @@ -385,6 +698,78 @@ func file_poker_proto_init() { return nil } } + file_poker_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReqLobbyView); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poker_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResLobbyView); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poker_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReqCreateTable); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poker_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResCreateTable); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poker_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReqJoinTable); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_poker_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResJoinTable); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -392,7 +777,7 @@ func file_poker_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_poker_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 12, NumExtensions: 0, NumServices: 0, }, diff --git a/api/poker.proto b/api/poker.proto index 97f0a03..ab908cb 100644 --- a/api/poker.proto +++ b/api/poker.proto @@ -12,7 +12,8 @@ message ProtoWrap { int32 ver = 1; // version int32 op = 2; // option/action int32 seq = 3; // sequence - bytes body = 4; // proto bytes + bool success = 4; // 请求是否成功 + bytes body = 7; // proto bytes } message Ping { @@ -23,6 +24,11 @@ message Pong { } +// 失败响应 +message ResFail { + string msg = 3; // 失败消息 +} + message ReqIdentity { string token = 1; } @@ -31,3 +37,27 @@ message ResIdentity { int32 status = 1; string msg = 2; } + +message ReqLobbyView { + +} + +message ResLobbyView { + +} + +message ReqCreateTable { + +} + +message ResCreateTable { + +} + +message ReqJoinTable { + +} + +message ResJoinTable { + +} diff --git a/api/proto.js b/api/proto.js index 3a20f59..c4001f2 100644 --- a/api/proto.js +++ b/api/proto.js @@ -25,6 +25,7 @@ export const api = $root.api = (() => { * @property {number|null} [ver] ProtoWrap ver * @property {number|null} [op] ProtoWrap op * @property {number|null} [seq] ProtoWrap seq + * @property {boolean|null} [success] ProtoWrap success * @property {Uint8Array|null} [body] ProtoWrap body */ @@ -67,6 +68,14 @@ export const api = $root.api = (() => { */ ProtoWrap.prototype.seq = 0; + /** + * ProtoWrap success. + * @member {boolean} success + * @memberof api.ProtoWrap + * @instance + */ + ProtoWrap.prototype.success = false; + /** * ProtoWrap body. * @member {Uint8Array} body @@ -105,8 +114,10 @@ export const api = $root.api = (() => { writer.uint32(/* id 2, wireType 0 =*/16).int32(message.op); if (message.seq != null && Object.hasOwnProperty.call(message, "seq")) writer.uint32(/* id 3, wireType 0 =*/24).int32(message.seq); + if (message.success != null && Object.hasOwnProperty.call(message, "success")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.success); if (message.body != null && Object.hasOwnProperty.call(message, "body")) - writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.body); + writer.uint32(/* id 7, wireType 2 =*/58).bytes(message.body); return writer; }; @@ -154,6 +165,10 @@ export const api = $root.api = (() => { break; } case 4: { + message.success = reader.bool(); + break; + } + case 7: { message.body = reader.bytes(); break; } @@ -201,6 +216,9 @@ export const api = $root.api = (() => { if (message.seq != null && message.hasOwnProperty("seq")) if (!$util.isInteger(message.seq)) return "seq: integer expected"; + if (message.success != null && message.hasOwnProperty("success")) + if (typeof message.success !== "boolean") + return "success: boolean expected"; if (message.body != null && message.hasOwnProperty("body")) if (!(message.body && typeof message.body.length === "number" || $util.isString(message.body))) return "body: buffer expected"; @@ -225,6 +243,8 @@ export const api = $root.api = (() => { message.op = object.op | 0; if (object.seq != null) message.seq = object.seq | 0; + if (object.success != null) + message.success = Boolean(object.success); if (object.body != null) if (typeof object.body === "string") $util.base64.decode(object.body, message.body = $util.newBuffer($util.base64.length(object.body)), 0); @@ -250,6 +270,7 @@ export const api = $root.api = (() => { object.ver = 0; object.op = 0; object.seq = 0; + object.success = false; if (options.bytes === String) object.body = ""; else { @@ -264,6 +285,8 @@ export const api = $root.api = (() => { object.op = message.op; if (message.seq != null && message.hasOwnProperty("seq")) object.seq = message.seq; + if (message.success != null && message.hasOwnProperty("success")) + object.success = message.success; if (message.body != null && message.hasOwnProperty("body")) object.body = options.bytes === String ? $util.base64.encode(message.body, 0, message.body.length) : options.bytes === Array ? Array.prototype.slice.call(message.body) : message.body; return object; @@ -648,6 +671,209 @@ export const api = $root.api = (() => { return Pong; })(); + api.ResFail = (function() { + + /** + * Properties of a ResFail. + * @memberof api + * @interface IResFail + * @property {string|null} [msg] ResFail msg + */ + + /** + * Constructs a new ResFail. + * @memberof api + * @classdesc Represents a ResFail. + * @implements IResFail + * @constructor + * @param {api.IResFail=} [properties] Properties to set + */ + function ResFail(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]]; + } + + /** + * ResFail msg. + * @member {string} msg + * @memberof api.ResFail + * @instance + */ + ResFail.prototype.msg = ""; + + /** + * Creates a new ResFail instance using the specified properties. + * @function create + * @memberof api.ResFail + * @static + * @param {api.IResFail=} [properties] Properties to set + * @returns {api.ResFail} ResFail instance + */ + ResFail.create = function create(properties) { + return new ResFail(properties); + }; + + /** + * Encodes the specified ResFail message. Does not implicitly {@link api.ResFail.verify|verify} messages. + * @function encode + * @memberof api.ResFail + * @static + * @param {api.IResFail} message ResFail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResFail.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.msg != null && Object.hasOwnProperty.call(message, "msg")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.msg); + return writer; + }; + + /** + * Encodes the specified ResFail message, length delimited. Does not implicitly {@link api.ResFail.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResFail + * @static + * @param {api.IResFail} message ResFail message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResFail.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResFail message from the specified reader or buffer. + * @function decode + * @memberof api.ResFail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResFail} ResFail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResFail.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.ResFail(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.msg = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResFail message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResFail + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResFail} ResFail + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResFail.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResFail message. + * @function verify + * @memberof api.ResFail + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResFail.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.msg != null && message.hasOwnProperty("msg")) + if (!$util.isString(message.msg)) + return "msg: string expected"; + return null; + }; + + /** + * Creates a ResFail message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResFail + * @static + * @param {Object.} object Plain object + * @returns {api.ResFail} ResFail + */ + ResFail.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResFail) + return object; + let message = new $root.api.ResFail(); + if (object.msg != null) + message.msg = String(object.msg); + return message; + }; + + /** + * Creates a plain object from a ResFail message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResFail + * @static + * @param {api.ResFail} message ResFail + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResFail.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) + object.msg = ""; + if (message.msg != null && message.hasOwnProperty("msg")) + object.msg = message.msg; + return object; + }; + + /** + * Converts this ResFail to JSON. + * @function toJSON + * @memberof api.ResFail + * @instance + * @returns {Object.} JSON object + */ + ResFail.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResFail + * @function getTypeUrl + * @memberof api.ResFail + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResFail.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResFail"; + }; + + return ResFail; + })(); + api.ReqIdentity = (function() { /** @@ -1078,7 +1304,1272 @@ export const api = $root.api = (() => { return ResIdentity; })(); - return api; + api.ReqLobbyView = (function() { + + /** + * Properties of a ReqLobbyView. + * @memberof api + * @interface IReqLobbyView + */ + + /** + * Constructs a new ReqLobbyView. + * @memberof api + * @classdesc Represents a ReqLobbyView. + * @implements IReqLobbyView + * @constructor + * @param {api.IReqLobbyView=} [properties] Properties to set + */ + function ReqLobbyView(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 ReqLobbyView instance using the specified properties. + * @function create + * @memberof api.ReqLobbyView + * @static + * @param {api.IReqLobbyView=} [properties] Properties to set + * @returns {api.ReqLobbyView} ReqLobbyView instance + */ + ReqLobbyView.create = function create(properties) { + return new ReqLobbyView(properties); + }; + + /** + * Encodes the specified ReqLobbyView message. Does not implicitly {@link api.ReqLobbyView.verify|verify} messages. + * @function encode + * @memberof api.ReqLobbyView + * @static + * @param {api.IReqLobbyView} message ReqLobbyView message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqLobbyView.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ReqLobbyView message, length delimited. Does not implicitly {@link api.ReqLobbyView.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ReqLobbyView + * @static + * @param {api.IReqLobbyView} message ReqLobbyView message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqLobbyView.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReqLobbyView message from the specified reader or buffer. + * @function decode + * @memberof api.ReqLobbyView + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ReqLobbyView} ReqLobbyView + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqLobbyView.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.ReqLobbyView(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReqLobbyView message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ReqLobbyView + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ReqLobbyView} ReqLobbyView + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqLobbyView.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReqLobbyView message. + * @function verify + * @memberof api.ReqLobbyView + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReqLobbyView.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ReqLobbyView message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ReqLobbyView + * @static + * @param {Object.} object Plain object + * @returns {api.ReqLobbyView} ReqLobbyView + */ + ReqLobbyView.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqLobbyView) + return object; + return new $root.api.ReqLobbyView(); + }; + + /** + * Creates a plain object from a ReqLobbyView message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ReqLobbyView + * @static + * @param {api.ReqLobbyView} message ReqLobbyView + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReqLobbyView.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ReqLobbyView to JSON. + * @function toJSON + * @memberof api.ReqLobbyView + * @instance + * @returns {Object.} JSON object + */ + ReqLobbyView.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReqLobbyView + * @function getTypeUrl + * @memberof api.ReqLobbyView + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReqLobbyView.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ReqLobbyView"; + }; + + return ReqLobbyView; + })(); + + api.ResLobbyView = (function() { + + /** + * Properties of a ResLobbyView. + * @memberof api + * @interface IResLobbyView + */ + + /** + * Constructs a new ResLobbyView. + * @memberof api + * @classdesc Represents a ResLobbyView. + * @implements IResLobbyView + * @constructor + * @param {api.IResLobbyView=} [properties] Properties to set + */ + function ResLobbyView(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 ResLobbyView instance using the specified properties. + * @function create + * @memberof api.ResLobbyView + * @static + * @param {api.IResLobbyView=} [properties] Properties to set + * @returns {api.ResLobbyView} ResLobbyView instance + */ + ResLobbyView.create = function create(properties) { + return new ResLobbyView(properties); + }; + + /** + * Encodes the specified ResLobbyView message. Does not implicitly {@link api.ResLobbyView.verify|verify} messages. + * @function encode + * @memberof api.ResLobbyView + * @static + * @param {api.IResLobbyView} message ResLobbyView message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResLobbyView.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ResLobbyView message, length delimited. Does not implicitly {@link api.ResLobbyView.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResLobbyView + * @static + * @param {api.IResLobbyView} message ResLobbyView message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResLobbyView.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResLobbyView message from the specified reader or buffer. + * @function decode + * @memberof api.ResLobbyView + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResLobbyView} ResLobbyView + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResLobbyView.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.ResLobbyView(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResLobbyView message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResLobbyView + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResLobbyView} ResLobbyView + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResLobbyView.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResLobbyView message. + * @function verify + * @memberof api.ResLobbyView + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResLobbyView.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ResLobbyView message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResLobbyView + * @static + * @param {Object.} object Plain object + * @returns {api.ResLobbyView} ResLobbyView + */ + ResLobbyView.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResLobbyView) + return object; + return new $root.api.ResLobbyView(); + }; + + /** + * Creates a plain object from a ResLobbyView message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResLobbyView + * @static + * @param {api.ResLobbyView} message ResLobbyView + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResLobbyView.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ResLobbyView to JSON. + * @function toJSON + * @memberof api.ResLobbyView + * @instance + * @returns {Object.} JSON object + */ + ResLobbyView.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResLobbyView + * @function getTypeUrl + * @memberof api.ResLobbyView + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResLobbyView.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResLobbyView"; + }; + + return ResLobbyView; + })(); + + api.ReqCreateTable = (function() { + + /** + * Properties of a ReqCreateTable. + * @memberof api + * @interface IReqCreateTable + */ + + /** + * Constructs a new ReqCreateTable. + * @memberof api + * @classdesc Represents a ReqCreateTable. + * @implements IReqCreateTable + * @constructor + * @param {api.IReqCreateTable=} [properties] Properties to set + */ + function ReqCreateTable(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 ReqCreateTable instance using the specified properties. + * @function create + * @memberof api.ReqCreateTable + * @static + * @param {api.IReqCreateTable=} [properties] Properties to set + * @returns {api.ReqCreateTable} ReqCreateTable instance + */ + ReqCreateTable.create = function create(properties) { + return new ReqCreateTable(properties); + }; + + /** + * Encodes the specified ReqCreateTable message. Does not implicitly {@link api.ReqCreateTable.verify|verify} messages. + * @function encode + * @memberof api.ReqCreateTable + * @static + * @param {api.IReqCreateTable} message ReqCreateTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqCreateTable.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ReqCreateTable message, length delimited. Does not implicitly {@link api.ReqCreateTable.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ReqCreateTable + * @static + * @param {api.IReqCreateTable} message ReqCreateTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqCreateTable.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReqCreateTable message from the specified reader or buffer. + * @function decode + * @memberof api.ReqCreateTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ReqCreateTable} ReqCreateTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqCreateTable.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.ReqCreateTable(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReqCreateTable message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ReqCreateTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ReqCreateTable} ReqCreateTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqCreateTable.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReqCreateTable message. + * @function verify + * @memberof api.ReqCreateTable + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReqCreateTable.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ReqCreateTable message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ReqCreateTable + * @static + * @param {Object.} object Plain object + * @returns {api.ReqCreateTable} ReqCreateTable + */ + ReqCreateTable.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqCreateTable) + return object; + return new $root.api.ReqCreateTable(); + }; + + /** + * Creates a plain object from a ReqCreateTable message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ReqCreateTable + * @static + * @param {api.ReqCreateTable} message ReqCreateTable + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReqCreateTable.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ReqCreateTable to JSON. + * @function toJSON + * @memberof api.ReqCreateTable + * @instance + * @returns {Object.} JSON object + */ + ReqCreateTable.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReqCreateTable + * @function getTypeUrl + * @memberof api.ReqCreateTable + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReqCreateTable.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ReqCreateTable"; + }; + + return ReqCreateTable; + })(); + + api.ResCreateTable = (function() { + + /** + * Properties of a ResCreateTable. + * @memberof api + * @interface IResCreateTable + */ + + /** + * Constructs a new ResCreateTable. + * @memberof api + * @classdesc Represents a ResCreateTable. + * @implements IResCreateTable + * @constructor + * @param {api.IResCreateTable=} [properties] Properties to set + */ + function ResCreateTable(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 ResCreateTable instance using the specified properties. + * @function create + * @memberof api.ResCreateTable + * @static + * @param {api.IResCreateTable=} [properties] Properties to set + * @returns {api.ResCreateTable} ResCreateTable instance + */ + ResCreateTable.create = function create(properties) { + return new ResCreateTable(properties); + }; + + /** + * Encodes the specified ResCreateTable message. Does not implicitly {@link api.ResCreateTable.verify|verify} messages. + * @function encode + * @memberof api.ResCreateTable + * @static + * @param {api.IResCreateTable} message ResCreateTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResCreateTable.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ResCreateTable message, length delimited. Does not implicitly {@link api.ResCreateTable.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResCreateTable + * @static + * @param {api.IResCreateTable} message ResCreateTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResCreateTable.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResCreateTable message from the specified reader or buffer. + * @function decode + * @memberof api.ResCreateTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResCreateTable} ResCreateTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResCreateTable.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.ResCreateTable(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResCreateTable message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResCreateTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResCreateTable} ResCreateTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResCreateTable.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResCreateTable message. + * @function verify + * @memberof api.ResCreateTable + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResCreateTable.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ResCreateTable message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResCreateTable + * @static + * @param {Object.} object Plain object + * @returns {api.ResCreateTable} ResCreateTable + */ + ResCreateTable.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResCreateTable) + return object; + return new $root.api.ResCreateTable(); + }; + + /** + * Creates a plain object from a ResCreateTable message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResCreateTable + * @static + * @param {api.ResCreateTable} message ResCreateTable + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResCreateTable.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ResCreateTable to JSON. + * @function toJSON + * @memberof api.ResCreateTable + * @instance + * @returns {Object.} JSON object + */ + ResCreateTable.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResCreateTable + * @function getTypeUrl + * @memberof api.ResCreateTable + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResCreateTable.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResCreateTable"; + }; + + return ResCreateTable; + })(); + + api.ReqJoinTable = (function() { + + /** + * Properties of a ReqJoinTable. + * @memberof api + * @interface IReqJoinTable + */ + + /** + * Constructs a new ReqJoinTable. + * @memberof api + * @classdesc Represents a ReqJoinTable. + * @implements IReqJoinTable + * @constructor + * @param {api.IReqJoinTable=} [properties] Properties to set + */ + function ReqJoinTable(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 ReqJoinTable instance using the specified properties. + * @function create + * @memberof api.ReqJoinTable + * @static + * @param {api.IReqJoinTable=} [properties] Properties to set + * @returns {api.ReqJoinTable} ReqJoinTable instance + */ + ReqJoinTable.create = function create(properties) { + return new ReqJoinTable(properties); + }; + + /** + * Encodes the specified ReqJoinTable message. Does not implicitly {@link api.ReqJoinTable.verify|verify} messages. + * @function encode + * @memberof api.ReqJoinTable + * @static + * @param {api.IReqJoinTable} message ReqJoinTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqJoinTable.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ReqJoinTable message, length delimited. Does not implicitly {@link api.ReqJoinTable.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ReqJoinTable + * @static + * @param {api.IReqJoinTable} message ReqJoinTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqJoinTable.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReqJoinTable message from the specified reader or buffer. + * @function decode + * @memberof api.ReqJoinTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ReqJoinTable} ReqJoinTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqJoinTable.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.ReqJoinTable(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReqJoinTable message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ReqJoinTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ReqJoinTable} ReqJoinTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqJoinTable.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReqJoinTable message. + * @function verify + * @memberof api.ReqJoinTable + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReqJoinTable.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ReqJoinTable message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ReqJoinTable + * @static + * @param {Object.} object Plain object + * @returns {api.ReqJoinTable} ReqJoinTable + */ + ReqJoinTable.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqJoinTable) + return object; + return new $root.api.ReqJoinTable(); + }; + + /** + * Creates a plain object from a ReqJoinTable message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ReqJoinTable + * @static + * @param {api.ReqJoinTable} message ReqJoinTable + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReqJoinTable.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ReqJoinTable to JSON. + * @function toJSON + * @memberof api.ReqJoinTable + * @instance + * @returns {Object.} JSON object + */ + ReqJoinTable.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReqJoinTable + * @function getTypeUrl + * @memberof api.ReqJoinTable + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReqJoinTable.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ReqJoinTable"; + }; + + return ReqJoinTable; + })(); + + api.ResJoinTable = (function() { + + /** + * Properties of a ResJoinTable. + * @memberof api + * @interface IResJoinTable + */ + + /** + * Constructs a new ResJoinTable. + * @memberof api + * @classdesc Represents a ResJoinTable. + * @implements IResJoinTable + * @constructor + * @param {api.IResJoinTable=} [properties] Properties to set + */ + function ResJoinTable(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 ResJoinTable instance using the specified properties. + * @function create + * @memberof api.ResJoinTable + * @static + * @param {api.IResJoinTable=} [properties] Properties to set + * @returns {api.ResJoinTable} ResJoinTable instance + */ + ResJoinTable.create = function create(properties) { + return new ResJoinTable(properties); + }; + + /** + * Encodes the specified ResJoinTable message. Does not implicitly {@link api.ResJoinTable.verify|verify} messages. + * @function encode + * @memberof api.ResJoinTable + * @static + * @param {api.IResJoinTable} message ResJoinTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResJoinTable.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ResJoinTable message, length delimited. Does not implicitly {@link api.ResJoinTable.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResJoinTable + * @static + * @param {api.IResJoinTable} message ResJoinTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResJoinTable.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResJoinTable message from the specified reader or buffer. + * @function decode + * @memberof api.ResJoinTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResJoinTable} ResJoinTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResJoinTable.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.ResJoinTable(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResJoinTable message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResJoinTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResJoinTable} ResJoinTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResJoinTable.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResJoinTable message. + * @function verify + * @memberof api.ResJoinTable + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResJoinTable.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ResJoinTable message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResJoinTable + * @static + * @param {Object.} object Plain object + * @returns {api.ResJoinTable} ResJoinTable + */ + ResJoinTable.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResJoinTable) + return object; + return new $root.api.ResJoinTable(); + }; + + /** + * Creates a plain object from a ResJoinTable message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResJoinTable + * @static + * @param {api.ResJoinTable} message ResJoinTable + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResJoinTable.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ResJoinTable to JSON. + * @function toJSON + * @memberof api.ResJoinTable + * @instance + * @returns {Object.} JSON object + */ + ResJoinTable.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResJoinTable + * @function getTypeUrl + * @memberof api.ResJoinTable + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResJoinTable.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResJoinTable"; + }; + + return ResJoinTable; + })(); + + return api; +})(); + +export const test = $root.test = (() => { + + /** + * Namespace test. + * @exports test + * @namespace + */ + const test = {}; + + test.Test = (function() { + + /** + * Properties of a Test. + * @memberof test + * @interface ITest + * @property {string|null} [msg] Test msg + */ + + /** + * Constructs a new Test. + * @memberof test + * @classdesc Represents a Test. + * @implements ITest + * @constructor + * @param {test.ITest=} [properties] Properties to set + */ + function Test(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]]; + } + + /** + * Test msg. + * @member {string} msg + * @memberof test.Test + * @instance + */ + Test.prototype.msg = ""; + + /** + * Creates a new Test instance using the specified properties. + * @function create + * @memberof test.Test + * @static + * @param {test.ITest=} [properties] Properties to set + * @returns {test.Test} Test instance + */ + Test.create = function create(properties) { + return new Test(properties); + }; + + /** + * Encodes the specified Test message. Does not implicitly {@link test.Test.verify|verify} messages. + * @function encode + * @memberof test.Test + * @static + * @param {test.ITest} message Test message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Test.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.msg != null && Object.hasOwnProperty.call(message, "msg")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.msg); + return writer; + }; + + /** + * Encodes the specified Test message, length delimited. Does not implicitly {@link test.Test.verify|verify} messages. + * @function encodeDelimited + * @memberof test.Test + * @static + * @param {test.ITest} message Test message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Test.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Test message from the specified reader or buffer. + * @function decode + * @memberof test.Test + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {test.Test} Test + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Test.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.test.Test(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.msg = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Test message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof test.Test + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {test.Test} Test + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Test.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Test message. + * @function verify + * @memberof test.Test + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Test.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.msg != null && message.hasOwnProperty("msg")) + if (!$util.isString(message.msg)) + return "msg: string expected"; + return null; + }; + + /** + * Creates a Test message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof test.Test + * @static + * @param {Object.} object Plain object + * @returns {test.Test} Test + */ + Test.fromObject = function fromObject(object) { + if (object instanceof $root.test.Test) + return object; + let message = new $root.test.Test(); + if (object.msg != null) + message.msg = String(object.msg); + return message; + }; + + /** + * Creates a plain object from a Test message. Also converts values to other types if specified. + * @function toObject + * @memberof test.Test + * @static + * @param {test.Test} message Test + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Test.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) + object.msg = ""; + if (message.msg != null && message.hasOwnProperty("msg")) + object.msg = message.msg; + return object; + }; + + /** + * Converts this Test to JSON. + * @function toJSON + * @memberof test.Test + * @instance + * @returns {Object.} JSON object + */ + Test.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Test + * @function getTypeUrl + * @memberof test.Test + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Test.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/test.Test"; + }; + + return Test; + })(); + + return test; })(); export { $root as default }; diff --git a/cmd/main.go b/cmd/main.go index 75addce..8a72f76 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -15,5 +15,4 @@ func startServer() { func main() { startServer() - } diff --git a/internal/server/server.go b/internal/server/server.go index c8c51dd..a55f69c 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -19,7 +19,7 @@ func NewServer() *gin.Engine { conn := base.Group("/conn") // 消息映射关系 TODO 生成 json 放在前端 conn.GET("/opMap", func(ctx *gin.Context) { - ctx.JSON(http.StatusOK, gin.H{"data": gin.H{"offset": api.OpOffset, "opMap": api.GetOpNameMap()}}) + ctx.JSON(http.StatusOK, gin.H{"data": api.GetOpNameMap()}) }) // websocket conn.GET("/ws", Upgrade) diff --git a/internal/server/ws.go b/internal/server/ws.go index ba707c2..d75b586 100644 --- a/internal/server/ws.go +++ b/internal/server/ws.go @@ -106,20 +106,20 @@ func handleNetClient(client *session.NetClient) { } } } - // TODO 处理请求对应消息响应 - fmt.Println(called, res, resErr) - // 写响应 + // 处理请求对应消息响应 + // fmt.Println(called, res, resErr) + if resErr != nil { + // 错误消息 + client.WriteSeq(false, wrap.Seq, &api.ResFail{Msg: resErr.Error()}) + return + } if res != nil { - client.WriteSeq(wrap.Seq, res) + // 响应消息 + client.WriteSeq(true, wrap.Seq, res) + return } - // log not found handler wrap.Op fmt.Printf("not found handler for op %d, msg: %v", wrap.Op, msg) } } - -// handleIdentity TODO 通过 token 认证连接的身份 -//func handleIdentity(identity *message2.ReqIdentity, client *session.NetClient) { -// -//} diff --git a/internal/server/wsroute.go b/internal/server/wsroute.go index fe3c73d..82239c2 100644 --- a/internal/server/wsroute.go +++ b/internal/server/wsroute.go @@ -16,8 +16,8 @@ func init() { HandleNetClientMsg(&api.ReqIdentity{}, func(client *session.NetClient, msg *api.ReqIdentity) (proto.Message, error) { subject, err := service.DecodeSubject(msg.Token) if err != nil { - client.Close("authorize failed!") - return nil, nil + // client.Close("authorize failed!") + return nil, err } account := &session.NetAccount{Id: subject.Id, UserName: subject.Name, Client: client} client.Account = account diff --git a/internal/session/net_client.go b/internal/session/net_client.go index cc7c8ff..33874c7 100644 --- a/internal/session/net_client.go +++ b/internal/session/net_client.go @@ -22,16 +22,16 @@ func (c *NetClient) Close(reason string) { } func (c *NetClient) Write(msg proto.Message) { - c.WriteSeq(0, msg) + c.WriteSeq(true, 0, msg) } -func (c *NetClient) WriteSeq(seq int32, msg proto.Message) { +func (c *NetClient) WriteSeq(success bool, seq int32, msg proto.Message) { op, err := api.GetProtoOp(msg) if err != nil { return } bytes, err := proto.Marshal(msg) - wrap := &api.ProtoWrap{Ver: 1, Op: op, Seq: seq, Body: bytes} + wrap := &api.ProtoWrap{Ver: 1, Op: op, Seq: seq, Success: success, Body: bytes} wrapBytes, err := proto.Marshal(wrap) err = c.Conn.WriteMessage(websocket.BinaryMessage, wrapBytes) }