From dba48754d9623a49b155e94c65341b773bf4eeef Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期五, 31 七月 2020 09:37:27 +0800 Subject: [PATCH] add get topic key --- library.go | 112 ++++++--- softbus.proto | 11 softbus.pb.go | 576 ++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 614 insertions(+), 85 deletions(-) diff --git a/library.go b/library.go index 242ac00..d81f0ce 100644 --- a/library.go +++ b/library.go @@ -3,6 +3,7 @@ import ( "context" "fmt" + "sync" "time" "github.com/golang/protobuf/proto" @@ -17,12 +18,12 @@ GetTopicInfoTypeChannel = "getchannel" ) -type subOReply struct { +type sockServer struct { sock *DgramSocket info *ProcInfo } -type sockRe struct { +type sockClient struct { sock *DgramSocket peer int } @@ -34,21 +35,31 @@ } // Handle handler +/* +sockHB/sockPub/sockWorker鍙互浣跨敤涓�涓猻ocket +浣嗘槸鐢变簬闇�瑕佹敮鎸佸绾跨▼涓斿績璺�/鍙戝竷閮芥槸寰堥噸瑕佺殑淇℃伅,鍗曠嫭涓�涓猻ocket澶勭悊 +worker澶勭悊鐭椂鐨勫彂閫� +*/ type Handle struct { ctx context.Context // 鍒涘缓channel瀵瑰簲鐨剅eply,绛夊緟璇诲彇鍏朵腑鐨勫唴瀹�,server // 鍏朵腑蹇呴』鏈変竴涓綔涓篟equest鍑芥暟鐨剆erver - m map[string]*subOReply - // 鍒涘缓蹇冭烦杩炴帴,client,浠呭彂閫佸績璺充俊鎭� - sockHB *sockRe - // 鍒涘缓鏇存柊涓婚杩炴帴,client,浠呭彂閫佷富棰樻洿鏂颁俊鎭� - sockUp *sockRe - // 鍒涘缓璁㈤槄鐨剆ocket - sockSub *subOReply + m map[string]*sockServer // 鍒涘缓reply鏈嶅姟Request鍑芥暟 - sockRep *sockRe + sockRep *sockServer + // 鍒涘缓蹇冭烦杩炴帴,client,浠呭彂閫佸績璺充俊鎭� + // 蹇冭烦闇�瑕佷繚璇佸崟鐙殑socket鍙戦��,濡傛灉璺熷叾浠栧叡鐢╯ocket,濡傛灉闃诲灏辨棤娉曞彂閫� + sockHB *sockClient + // 鍒涘缓鏇存柊涓婚杩炴帴,client,浠呭彂閫佷富棰樻洿鏂颁俊鎭� + // 鍙戦�佹湰韬殑pub淇℃伅,寰堝彲鑳藉叾浠栬繘绋嬩緷璧�,闇�瑕佸崟鐙瑂ocket澶勭悊 + sockPub *sockClient + // 鍒涘缓璁㈤槄鐨剆ocket + // 璁㈤槄鐨勪富棰樺彂閫佺殑娑堟伅 + sockSub *sockClient // 鍒涘缓涓�涓竾鑳絪ocket鍙戦�佺粰浠绘剰server - sockWorker *sockRe + sockWorker *sockClient + // 澶氱嚎绋� + mtxWorker sync.Mutex chSub chan TransInfo chReply chan TransInfo @@ -62,7 +73,7 @@ v.sock.Close() } h.sockHB.sock.Close() - h.sockUp.sock.Close() + h.sockPub.sock.Close() h.sockSub.sock.Close() h.sockRep.sock.Close() h.sockWorker.sock.Close() @@ -89,7 +100,7 @@ // Register reg func Register(ctx context.Context, info *RegisterInfo) *Handle { - m := make(map[string]*subOReply) + m := make(map[string]*sockServer) // 棣栧厛璇锋眰涓�鍫唊ey sockReg := OpenDgramSocket() @@ -125,12 +136,12 @@ return nil } - // 鏀跺彂req/rep channel + // 鏀跺彂req/rep channel, server for _, v := range info.Channel { if k, ok := regReply.ChannelKey[v]; ok { s := OpenDgramSocket() s.Bind(int(k)) - m[v] = &subOReply{ + m[v] = &sockServer{ sock: s, info: info.ProcInfo, } @@ -141,20 +152,29 @@ chSub := make(chan TransInfo, chSize) chReply := make(chan TransInfo, chSize) - // heartbeat浣跨敤涓�涓猻ocket + // reply浣跨敤涓�涓�,鏈嶅姟Request, server + sockReply := OpenDgramSocket() + sockReply.Bind(int(regReply.ReplyKey)) + // 鍚姩鎺ユ敹绾跨▼ + go recvRoutine(ctx, sockReply, chSub) + repS := &sockServer{ + sock: sockReply, + info: info.ProcInfo, + } + + // heartbeat浣跨敤涓�涓猻ocket, client sockHB := OpenDgramSocket() - hbr := &sockRe{ + hbC := &sockClient{ sock: sockHB, peer: int(regReply.HeartbeatKey), } - // 鏇存柊涓婚浣跨敤涓�涓� + // 鍙戝竷涓婚浣跨敤涓�涓�, client sockUp := OpenDgramSocket() - upr := &sockRe{ + pubC := &sockClient{ sock: sockUp, peer: int(regReply.UpdateTopicKey), } - - // sub浣跨敤涓�涓猻ocket + // sub浣跨敤涓�涓猻ocket, client sockSub := OpenDgramSocket() // sockSub.Bind(int(regReply.SubTopicKey)) // 璁㈤槄涓婚 @@ -163,34 +183,25 @@ } // 鍚姩鎺ユ敹绾跨▼ go recvRoutine(ctx, sockSub, chSub) - sub := &subOReply{ + subC := &sockClient{ sock: sockSub, - info: info.ProcInfo, - } - // reply浣跨敤涓�涓�,鏈嶅姟Request - sockReply := OpenDgramSocket() - sockReply.Bind(int(regReply.ReplyKey)) - // 鍚姩鎺ユ敹绾跨▼ - go recvRoutine(ctx, sockReply, chSub) - rer := &sockRe{ - sock: sockReply, peer: -1, } // 涓囪兘socket,浠呬綔涓哄鎴风浣跨敤 sockW := OpenDgramSocket() - swr := &sockRe{ + uniC := &sockClient{ sock: sockW, peer: -1, } handle := &Handle{ ctx: ctx, m: m, - sockHB: hbr, - sockUp: upr, - sockSub: sub, - sockRep: rer, - sockWorker: swr, + sockHB: hbC, + sockPub: pubC, + sockSub: subC, + sockRep: repS, + sockWorker: uniC, chSub: chSub, chReply: chReply, } @@ -207,11 +218,27 @@ if v, ok := h.m[topic]; ok { return v.sock.Port() } + // 杩滅▼鑾峰彇 + msg := &TopicInfo{ + Topic: topic, + TopicType: typ, + } + if data, err := proto.Marshal(msg); err == nil { + h.mtxWorker.Lock() + if rdata, err := h.sockWorker.sock.SendAndRecv(data, h.sockWorker.peer); err == nil { + h.mtxWorker.Unlock() + var rmsg *TopicInfoReply + if err := proto.Unmarshal(rdata, rmsg); err == nil { + return int(rmsg.Key) + } + } + h.mtxWorker.Unlock() + } return -1 } -func (h *Handle) send2(sr *sockRe, data []byte, logID string) error { - if r := sr.sock.SendTo(data, sr.peer); r != 0 { +func (h *Handle) send2(sc *sockClient, data []byte, logID string) error { + if r := sc.sock.SendTo(data, sc.peer); r != 0 { return fmt.Errorf("%s SendTo Failed: %d", logID, r) } return nil @@ -228,6 +255,8 @@ // SendOnly no recv func (h *Handle) SendOnly(key int, info *MsgInfo) error { + h.mtxWorker.Lock() + defer h.mtxWorker.Unlock() msg, err := proto.Marshal(info) if err == nil { if r := h.sockWorker.sock.SendTo(msg, key); r != 0 { @@ -241,13 +270,16 @@ func (h *Handle) Pub(info *MsgInfo) error { msg, err := proto.Marshal(info) if err == nil { - return h.send2(h.sockUp, msg, "Pub") + return h.send2(h.sockPub, msg, "Pub") } return err } // Request req sync func (h *Handle) Request(key int, info *MsgInfo) *MsgInfo { + h.mtxWorker.Lock() + defer h.mtxWorker.Unlock() + msg, err := proto.Marshal(info) if err != nil { return nil diff --git a/softbus.pb.go b/softbus.pb.go index 2eb3afa..4f63e7d 100644 --- a/softbus.pb.go +++ b/softbus.pb.go @@ -187,6 +187,7 @@ SubTopicKey int32 `protobuf:"varint,4,opt,name=subTopicKey,proto3" json:"subTopicKey,omitempty"` UpdateTopicKey int32 `protobuf:"varint,5,opt,name=updateTopicKey,proto3" json:"updateTopicKey,omitempty"` ReplyKey int32 `protobuf:"varint,6,opt,name=replyKey,proto3" json:"replyKey,omitempty"` + GetTopicKey int32 `protobuf:"varint,7,opt,name=getTopicKey,proto3" json:"getTopicKey,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -267,6 +268,123 @@ return 0 } +func (m *RegisterInfoReply) GetGetTopicKey() int32 { + if m != nil { + return m.GetTopicKey + } + return 0 +} + +type TopicInfo struct { + Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` + TopicType string `protobuf:"bytes,2,opt,name=topicType,proto3" json:"topicType,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TopicInfo) Reset() { *m = TopicInfo{} } +func (m *TopicInfo) String() string { return proto.CompactTextString(m) } +func (*TopicInfo) ProtoMessage() {} +func (*TopicInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_61abf516b68179fd, []int{3} +} +func (m *TopicInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TopicInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TopicInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TopicInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_TopicInfo.Merge(m, src) +} +func (m *TopicInfo) XXX_Size() int { + return m.Size() +} +func (m *TopicInfo) XXX_DiscardUnknown() { + xxx_messageInfo_TopicInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_TopicInfo proto.InternalMessageInfo + +func (m *TopicInfo) GetTopic() string { + if m != nil { + return m.Topic + } + return "" +} + +func (m *TopicInfo) GetTopicType() string { + if m != nil { + return m.TopicType + } + return "" +} + +type TopicInfoReply struct { + Info *TopicInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` + Key int32 `protobuf:"varint,2,opt,name=key,proto3" json:"key,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TopicInfoReply) Reset() { *m = TopicInfoReply{} } +func (m *TopicInfoReply) String() string { return proto.CompactTextString(m) } +func (*TopicInfoReply) ProtoMessage() {} +func (*TopicInfoReply) Descriptor() ([]byte, []int) { + return fileDescriptor_61abf516b68179fd, []int{4} +} +func (m *TopicInfoReply) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TopicInfoReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TopicInfoReply.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TopicInfoReply) XXX_Merge(src proto.Message) { + xxx_messageInfo_TopicInfoReply.Merge(m, src) +} +func (m *TopicInfoReply) XXX_Size() int { + return m.Size() +} +func (m *TopicInfoReply) XXX_DiscardUnknown() { + xxx_messageInfo_TopicInfoReply.DiscardUnknown(m) +} + +var xxx_messageInfo_TopicInfoReply proto.InternalMessageInfo + +func (m *TopicInfoReply) GetInfo() *TopicInfo { + if m != nil { + return m.Info + } + return nil +} + +func (m *TopicInfoReply) GetKey() int32 { + if m != nil { + return m.Key + } + return 0 +} + type HeartbeatInfo struct { HealthLevel string `protobuf:"bytes,1,opt,name=healthLevel,proto3" json:"healthLevel,omitempty"` Fps int32 `protobuf:"varint,2,opt,name=fps,proto3" json:"fps,omitempty"` @@ -284,7 +402,7 @@ func (m *HeartbeatInfo) String() string { return proto.CompactTextString(m) } func (*HeartbeatInfo) ProtoMessage() {} func (*HeartbeatInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_61abf516b68179fd, []int{3} + return fileDescriptor_61abf516b68179fd, []int{5} } func (m *HeartbeatInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -378,7 +496,7 @@ func (m *MsgInfo) String() string { return proto.CompactTextString(m) } func (*MsgInfo) ProtoMessage() {} func (*MsgInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_61abf516b68179fd, []int{4} + return fileDescriptor_61abf516b68179fd, []int{6} } func (m *MsgInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -454,6 +572,8 @@ proto.RegisterType((*RegisterInfo)(nil), "softbus.RegisterInfo") proto.RegisterType((*RegisterInfoReply)(nil), "softbus.RegisterInfoReply") proto.RegisterMapType((map[string]int32)(nil), "softbus.RegisterInfoReply.ChannelKeyEntry") + proto.RegisterType((*TopicInfo)(nil), "softbus.TopicInfo") + proto.RegisterType((*TopicInfoReply)(nil), "softbus.TopicInfoReply") proto.RegisterType((*HeartbeatInfo)(nil), "softbus.HeartbeatInfo") proto.RegisterType((*MsgInfo)(nil), "softbus.MsgInfo") } @@ -461,41 +581,45 @@ func init() { proto.RegisterFile("softbus.proto", fileDescriptor_61abf516b68179fd) } var fileDescriptor_61abf516b68179fd = []byte{ - // 534 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xdd, 0x8a, 0xd3, 0x40, - 0x14, 0x36, 0xfd, 0xdd, 0x3d, 0x6d, 0x75, 0x77, 0x10, 0x09, 0x8b, 0x94, 0x12, 0x44, 0x44, 0xb1, - 0x17, 0xeb, 0x8d, 0x08, 0xde, 0x68, 0x05, 0xab, 0x55, 0x4a, 0xdc, 0x17, 0x48, 0xda, 0xd3, 0xa6, - 0x98, 0x66, 0xc2, 0x64, 0x5a, 0x89, 0x2f, 0xe1, 0xad, 0x0f, 0x21, 0x3e, 0x87, 0x97, 0xde, 0x79, - 0x2b, 0xf5, 0x05, 0x7c, 0x04, 0x39, 0x27, 0x33, 0x69, 0xba, 0x22, 0xb2, 0x77, 0xe7, 0x3b, 0xe7, - 0x9b, 0xc9, 0xf7, 0xcd, 0x7c, 0x13, 0xe8, 0x65, 0x72, 0xa1, 0xc3, 0x4d, 0x36, 0x4c, 0x95, 0xd4, - 0x52, 0xb4, 0x0d, 0xf4, 0xbe, 0x3a, 0x70, 0x34, 0x55, 0x72, 0x36, 0x4e, 0x16, 0x52, 0x9c, 0xc1, - 0x51, 0x86, 0x6a, 0x8b, 0x6a, 0x3c, 0x72, 0x9d, 0x81, 0x73, 0xef, 0xd8, 0x2f, 0xb1, 0x70, 0xa1, - 0x1d, 0xca, 0x40, 0xcd, 0xc7, 0x23, 0xb7, 0xc6, 0x23, 0x0b, 0x2b, 0xab, 0xa6, 0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0xbe, 0xef, 0xfa, 0xce, 0xcf, 0x5d, 0xdf, 0xf9, 0xfc, - 0xab, 0x7f, 0x2d, 0x6c, 0xf1, 0x0f, 0xe6, 0xd1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9f, 0x8a, - 0x04, 0x17, 0x71, 0x04, 0x00, 0x00, + // 593 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xd1, 0x8a, 0xd3, 0x5c, + 0x10, 0xfe, 0xd3, 0x36, 0xcd, 0xee, 0xb4, 0xdd, 0x7f, 0xf7, 0xb0, 0x2c, 0x61, 0x91, 0x52, 0x82, + 0x2c, 0xa2, 0xd8, 0x8b, 0xf5, 0x46, 0x04, 0x11, 0xb4, 0x82, 0x5d, 0xab, 0x94, 0xb8, 0x2f, 0x90, + 0xb4, 0xd3, 0xa6, 0x98, 0x26, 0xe1, 0x24, 0xad, 0xc4, 0x97, 0xf0, 0xd6, 0x87, 0x10, 0x9f, 0xc3, + 0x4b, 0x1f, 0x41, 0xea, 0x0b, 0x78, 0xeb, 0x9d, 0xcc, 0xe4, 0x9c, 0x24, 0x5d, 0x11, 0xf1, 0x6e, + 0xbe, 0x99, 0xef, 0xcc, 0xf9, 0xe6, 0xcc, 0x97, 0x40, 0x2f, 0x8d, 0x17, 0x99, 0xbf, 0x49, 0x87, + 0x89, 0x8c, 0xb3, 0x58, 0x58, 0x0a, 0x3a, 0x9f, 0x0d, 0x38, 0x98, 0xca, 0x78, 0x36, 0x8e, 0x16, + 0xb1, 0x38, 0x87, 0x83, 0x14, 0xe5, 0x16, 0xe5, 0x78, 0x64, 0x1b, 0x03, 0xe3, 0xce, 0xa1, 0x5b, + 0x62, 0x61, 0x83, 0xe5, 0xc7, 0x9e, 0x9c, 0x8f, 0x47, 0x76, 0x83, 0x4b, 0x1a, 0xd6, 0x4e, 0x4d, + 0xed, 0xe6, 0xde, 0xa9,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, + 0xfd, 0xd9, 0xf0, 0x9a, 0x41, 0x9f, 0xe1, 0x3a, 0x5d, 0xd6, 0x76, 0xa2, 0x61, 0xb5, 0xc5, 0x66, + 0x7d, 0x8b, 0x67, 0xd0, 0x4e, 0x83, 0x75, 0x65, 0x55, 0x85, 0x84, 0x80, 0x96, 0x1f, 0xcf, 0x73, + 0x35, 0x2e, 0xc7, 0xc5, 0xaf, 0x6a, 0x9e, 0x4f, 0x30, 0x52, 0x33, 0x6a, 0xf8, 0xf4, 0xf8, 0xcb, + 0xae, 0x6f, 0x7c, 0xdd, 0xf5, 0x8d, 0x6f, 0xbb, 0xbe, 0xf1, 0xf1, 0x7b, 0xff, 0x3f, 0xbf, 0xcd, + 0xff, 0xc3, 0x07, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x65, 0x52, 0xb8, 0x9f, 0x20, 0x05, 0x00, + 0x00, } func (m *ProcInfo) Marshal() (dAtA []byte, err error) { @@ -692,6 +816,80 @@ i++ i = encodeVarintSoftbus(dAtA, i, uint64(m.ReplyKey)) } + if m.GetTopicKey != 0 { + dAtA[i] = 0x38 + i++ + i = encodeVarintSoftbus(dAtA, i, uint64(m.GetTopicKey)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *TopicInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TopicInfo) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Topic) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintSoftbus(dAtA, i, uint64(len(m.Topic))) + i += copy(dAtA[i:], m.Topic) + } + if len(m.TopicType) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintSoftbus(dAtA, i, uint64(len(m.TopicType))) + i += copy(dAtA[i:], m.TopicType) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *TopicInfoReply) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TopicInfoReply) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Info != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintSoftbus(dAtA, i, uint64(m.Info.Size())) + n3, err3 := m.Info.MarshalTo(dAtA[i:]) + if err3 != nil { + return 0, err3 + } + i += n3 + } + if m.Key != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintSoftbus(dAtA, i, uint64(m.Key)) + } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -751,11 +949,11 @@ dAtA[i] = 0x3a i++ i = encodeVarintSoftbus(dAtA, i, uint64(m.ProcInfo.Size())) - n3, err3 := m.ProcInfo.MarshalTo(dAtA[i:]) - if err3 != nil { - return 0, err3 + n4, err4 := m.ProcInfo.MarshalTo(dAtA[i:]) + if err4 != nil { + return 0, err4 } - i += n3 + i += n4 } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) @@ -782,11 +980,11 @@ dAtA[i] = 0xa i++ i = encodeVarintSoftbus(dAtA, i, uint64(m.SrcProc.Size())) - n4, err4 := m.SrcProc.MarshalTo(dAtA[i:]) - if err4 != nil { - return 0, err4 + n5, err5 := m.SrcProc.MarshalTo(dAtA[i:]) + if err5 != nil { + return 0, err5 } - i += n4 + i += n5 } if len(m.MsgType) > 0 { dAtA[i] = 0x12 @@ -930,6 +1128,48 @@ } if m.ReplyKey != 0 { n += 1 + sovSoftbus(uint64(m.ReplyKey)) + } + if m.GetTopicKey != 0 { + n += 1 + sovSoftbus(uint64(m.GetTopicKey)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *TopicInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Topic) + if l > 0 { + n += 1 + l + sovSoftbus(uint64(l)) + } + l = len(m.TopicType) + if l > 0 { + n += 1 + l + sovSoftbus(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *TopicInfoReply) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Info != nil { + l = m.Info.Size() + n += 1 + l + sovSoftbus(uint64(l)) + } + if m.Key != 0 { + n += 1 + sovSoftbus(uint64(m.Key)) } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) @@ -1708,6 +1948,252 @@ break } } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GetTopicKey", wireType) + } + m.GetTopicKey = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSoftbus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GetTopicKey |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSoftbus(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSoftbus + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthSoftbus + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TopicInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSoftbus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TopicInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TopicInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Topic", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSoftbus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSoftbus + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSoftbus + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Topic = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TopicType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSoftbus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSoftbus + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSoftbus + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TopicType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSoftbus(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthSoftbus + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthSoftbus + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TopicInfoReply) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSoftbus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TopicInfoReply: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TopicInfoReply: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSoftbus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSoftbus + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSoftbus + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Info == nil { + m.Info = &TopicInfo{} + } + if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + m.Key = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSoftbus + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Key |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipSoftbus(dAtA[iNdEx:]) diff --git a/softbus.proto b/softbus.proto index e70760b..ce076f8 100644 --- a/softbus.proto +++ b/softbus.proto @@ -26,6 +26,17 @@ int32 subTopicKey = 4; int32 updateTopicKey = 5; int32 replyKey = 6; + int32 getTopicKey = 7; +} + +message TopicInfo{ + string topic = 1; + string topicType = 2; +} + +message TopicInfoReply{ + TopicInfo info = 1; + int32 key = 2; } message HeartbeatInfo { -- Gitblit v1.8.0