Ejemplo n.º 1
0
func MakeNewPostMan() *PostMan {
	pm := &PostMan{
		MBS: utils.MakeNewSafeStrMap(),
	}
	pm.InitMsgBox()
	return pm
}
Ejemplo n.º 2
0
//创建一个信箱,每个信箱限制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
}