game.go 936 B

123456789101112131415161718192021222324252627282930313233343536
  1. package rpcGame
  2. import (
  3. "fmt"
  4. cfacade "github.com/mhaya/facade"
  5. "github.com/mhaya/game/game_cluster/internal/pb"
  6. sessionKey "github.com/mhaya/game/game_cluster/internal/session_key"
  7. clog "github.com/mhaya/logger"
  8. cproto "github.com/mhaya/net/proto"
  9. )
  10. const (
  11. playerActor = "player"
  12. )
  13. const (
  14. sessionClose = "sessionClose"
  15. )
  16. const (
  17. sourcePath = ".system"
  18. )
  19. // SessionClose 如果session已登录,则调用rpcGame.SessionClose() 告知游戏服
  20. func SessionClose(app cfacade.IApplication, session *cproto.Session) {
  21. nodeId := session.GetString(sessionKey.TargetPath)
  22. if nodeId == "" {
  23. clog.Warnf("Get server id fail. session = %s", session.Sid)
  24. return
  25. }
  26. targetPath := fmt.Sprintf("%s.%s.%s", nodeId, playerActor, session.Sid)
  27. app.ActorSystem().Call("", targetPath, sessionClose, &pb.Int64{
  28. Value: session.Uid,
  29. })
  30. //clog.Infof("send close session to game node. [node = %s, uid = %d]", nodeId, session.Uid)
  31. }