data_key.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package sessions
  2. import (
  3. cproto "github.com/cherry-game/cherry/net/proto"
  4. )
  5. // 根据session对象获取以下值
  6. const (
  7. UID = "uid" // int64 uid
  8. SID = "sid" // string sid
  9. AgentPath = "agent_path" // agent path
  10. GameNodeID = "game_node_id" // int32 游戏服务器ID
  11. OpenID = "open_id" // string 第三方登录sdk的用户唯一标识
  12. PID = "pid" // int32 sdk安装包id
  13. PlayerID = "player_id" // int64 玩家id
  14. IsNewPlayer = "is_new_player" // bool 是否为新玩家
  15. LeagueID = "league_id" // int64 联盟ID
  16. Language = "language" // string 语言
  17. MapNodeID = "map_node_id" // string 地图节点ID
  18. IsOnline = "is_online" // bool 是否在线
  19. )
  20. func GetGameNodeID(session *cproto.Session) string {
  21. return session.GetString(GameNodeID)
  22. }
  23. func GetOpenID(session *cproto.Session) string {
  24. return session.GetString(OpenID)
  25. }
  26. func GetPID(session *cproto.Session) int32 {
  27. return session.GetInt32(PID)
  28. }
  29. func GetPlayerID(session *cproto.Session) int64 {
  30. return session.GetInt64(PlayerID)
  31. }
  32. func GetPlayerIDValue(session *cproto.Session) string {
  33. return session.GetString(PlayerID)
  34. }
  35. func GetLeagueID(session *cproto.Session) int64 {
  36. return session.GetInt64(LeagueID)
  37. }
  38. func GetMapNodeID(session *cproto.Session) string {
  39. return session.GetString(MapNodeID)
  40. }