func MakeNewPostMan() *PostMan { pm := &PostMan{ MBS: utils.MakeNewSafeStrMap(), } pm.InitMsgBox() return pm }
//创建一个信箱,每个信箱限制2000条信息上限,超过上限,删除比较老的信息 func MakeNewMsgBox(id int, pm *PostMan) *MsgBox { mb := &MsgBox{ BoxId: id, MB: utils.MakeNewSafeQueue(2000), ExistMsg: make(chan bool), MBM: pm, Conns: utils.MakeNewSafeStrMap(), lock: new(sync.RWMutex), ConnIndex: 0, } mb.Load() go mb.Sender() return mb }