예제 #1
0
파일: baseplayer.go 프로젝트: mysll/flynet
func (p *BasePlayer) updatemin(intervalid server.TimerID, count int32, args interface{}) {
	p.CheckNewDay()
	//任务更新
	App.tasksystem.OnUpdate(p.Entity.(*entity.Player))
	//清理过期的邮件
	DeleteExpiredLetter(p.Entity.(*entity.Player))
	db := server.GetAppByType("database")
	if db != nil {
		server.NewDBWarp(db).LookLetter(nil, p.Entity.GetDbId(), "DbBridge.LookLetterBack", share.DBParams{"mailbox": p.Mailbox})
	}

}
예제 #2
0
파일: db.go 프로젝트: mysll/flynet
func (d *DbBridge) LookLetterBack(mailbox rpc.Mailbox, msg *rpc.Message) (errcode int32, reply *rpc.Message) {
	params := share.DBParams{}
	r := server.NewMessageReader(msg)
	if server.Check(r.ReadObject(&params)) {
		return 0, nil
	}

	if !params["result"].(bool) {
		return 0, nil
	}

	mailbox = params["mailbox"].(rpc.Mailbox)
	p := App.Players.GetPlayer(mailbox.Id)
	if p == nil {
		log.LogError("player not found, id:", mailbox.Id)
		//角色没有找到
		return 0, nil
	}
	player := p.Entity.(*entity.Player)

	db := server.GetAppByType("database")
	if db == nil {
		log.LogError(server.ErrAppNotFound)
		return 0, nil
	}

	warp := server.NewDBWarp(db)
	letters := params["letters"].([]*share.LetterInfo)
	for _, letter := range letters {
		idx := player.MailBox_r.AddRowValue(-1, letter.Source, letter.Source_name, util.UTC2Loc(letter.Send_time.Time.UTC()).Unix(), letter.Title, letter.Content, letter.Appendix, 0, letter.Serial_no, letter.Msg_type)
		if idx == -1 {
			//邮箱满了
			server.Error(nil, &mailbox, "Letter.Error", ERR_MAILBOX_FULL)
			break
		}
		//删信
		warp.RecvLetter(nil, player.GetDbId(), letter.Serial_no, "_", share.DBParams{})
	}

	return 0, nil
}