actor_dbs.go 711 B

1234567891011121314151617181920212223242526272829303132333435
  1. package module
  2. import (
  3. cfacade "github.com/mhaya/facade"
  4. "github.com/mhaya/game/game_cluster/internal/mdb/models"
  5. "github.com/mhaya/net/parser/simple"
  6. )
  7. type (
  8. // ActorDBs 玩家总管理actor
  9. ActorDBs struct {
  10. simple.ActorBase
  11. }
  12. )
  13. func (p *ActorDBs) AliasID() string {
  14. return "dbs"
  15. }
  16. func (p *ActorDBs) OnInit() {
  17. playerIdMap = make(map[string]*models.Player)
  18. accountIdMap = make(map[string]*models.Account)
  19. }
  20. func (p *ActorDBs) OnFindChild(msg *cfacade.Message) (cfacade.IActor, bool) {
  21. // 动态创建 player child actor
  22. childID := msg.TargetPath().ChildID
  23. childActor, err := p.Child().Create(childID, &ActorDBChild{})
  24. if err != nil {
  25. return nil, false
  26. }
  27. return childActor, true
  28. }