Skip to content

Commit

Permalink
return msg id
Browse files Browse the repository at this point in the history
  • Loading branch information
name5566 committed Aug 18, 2016
1 parent b5fe200 commit ae19568
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions network/protobuf/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (p *Processor) SetByteOrder(littleEndian bool) {
}

// It's dangerous to call the method on routing or marshaling (unmarshaling)
func (p *Processor) Register(msg proto.Message) {
func (p *Processor) Register(msg proto.Message) uint16 {
msgType := reflect.TypeOf(msg)
if msgType == nil || msgType.Kind() != reflect.Ptr {
log.Fatal("protobuf message pointer required")
Expand All @@ -56,7 +56,9 @@ func (p *Processor) Register(msg proto.Message) {
i := new(MsgInfo)
i.msgType = msgType
p.msgInfo = append(p.msgInfo, i)
p.msgID[msgType] = uint16(len(p.msgInfo) - 1)
id := uint16(len(p.msgInfo) - 1)
p.msgID[msgType] = id
return id
}

// It's dangerous to call the method on routing or marshaling (unmarshaling)
Expand Down

0 comments on commit ae19568

Please sign in to comment.