Skip to content

Commit

Permalink
msgbox
Browse files Browse the repository at this point in the history
  • Loading branch information
LinNan committed Nov 3, 2017
1 parent a9261aa commit 753e981
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ext/msgbox/msgbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (mbs *MsgboxService) Send(targetID common.EntityID, msg Msg) {
if err != nil {
gwlog.Panic(err)
}
gwlog.Debugf("Msg is sent ok")
gwlog.Debugf("Msg %s is sent ok", msgkey)
})
}

Expand All @@ -80,7 +80,7 @@ func (mbs *MsgboxService) Recv(targetID common.EntityID, beginMsgId int64) {
}

if len(items) == 0 {
gwlog.Debugf("found no msg")
gwlog.Debugf("found no msg from %s ~ %s", beginKey, endKey)
return
}

Expand All @@ -99,7 +99,11 @@ func (mbs *MsgboxService) Recv(targetID common.EntityID, beginMsgId int64) {
msgs = append(msgs, msg)

}

if endMsgId > mbs.Attrs.GetInt("maxMsgId") {
// message saved in kvdb has larger id than maxMsgId, something goes wrong
gwlog.Errorf("%s.Recv: max msg id is %d, but received msg id %d, fixing ...", mbs, mbs.GetInt("maxMsgId"), endMsgId)
mbs.Attrs.SetInt("maxMsgId", endMsgId+10000)
}
mbs.Call(targetID, "MsgboxOnRecvMsg", beginMsgId, endMsgId, msgs)
})
}
Expand Down Expand Up @@ -148,7 +152,7 @@ func (mb *Msgbox) Recv() {
}

func (mb *Msgbox) MsgboxOnRecvMsg(beginMsgId int64, endMsgId int64, msgs []Msg) {
gwlog.Debugf("%s: MsgBox.OnRecvMsg: %d -> %d: msgs %v", mb.Entity, beginMsgId, endMsgId, msgs)
gwlog.Debugf("%s: MsgBox.OnRecvMsg: %d -> %d: %d msgs", mb.Entity, beginMsgId, endMsgId, len(msgs))
mb.Attrs.SetInt(_LastMsgboxMsgIdAttrKey, endMsgId)
for _, msg := range msgs {
gwutils.RunPanicless(func() {
Expand Down

0 comments on commit 753e981

Please sign in to comment.