Exemplo n.º 1
0
//获取用户详细信息
func (this UserModule) GetUserInfo(userID uint64, session *link.Session) {
	onlineUser := module.Cache.GetOnlineUserByUserID(userID)
	if onlineUser != nil {
		dbUser := redisProxy.GetDBUser(userID)
		if dbUser != nil {
			userModel := NewUserModel(dbUser)
			gameProxy.SendGetUserInfoResult(session, 0, userModel)
		} else {
			gameProxy.SendGetUserInfoResult(session, gameProto.User_Not_Exists, nil)
		}
	} else {
		gameProxy.SendGetUserInfoResult(session, gameProto.User_Login_Fail, nil)
	}
}
Exemplo n.º 2
0
//获取用户详细信息
func (this UserModule) GetUserInfo(userID uint64, session *link.Session) {
	onlineUser := module.Cache.GetOnlineUserByUserID(userID)
	if onlineUser != nil {
		dbUser := redisProxy.GetDBUser(userID)
		if dbUser != nil {
			userModel := NewUserModel(dbUser)
			module.SendGetUserInfoResult(0, userModel, session)

			//更新用户最后上线时间,更新内存和数据库
			nowTime := time.Now().Unix()
			redisProxy.UpdateUserLastLoginTime(userID, nowTime)
			dbProxy.UpdateUserLastLoginTime(session.Id(), userID, nowTime)

		} else {
			module.SendGetUserInfoResult(gameProto.User_Not_Exists, nil, session)
		}
	} else {
		module.SendGetUserInfoResult(gameProto.User_Login_Fail, nil, session)
	}
}