| | |
| | |
|
| | | import traceback
|
| | | import base64
|
| | | #import pymongo
|
| | | import pymongo
|
| | | import datetime
|
| | |
|
| | |
|
| | |
| | |
|
| | | self.PlayerOffTime = config.GetPlayerOffTime() #玩家下线时长
|
| | | self.ServerDBConfigPath = config.GetServerDBConfigPath() #数据库路径
|
| | | #self.InitDBCon()
|
| | | self.InitDBCon()
|
| | |
|
| | | self.tokenList = [] # 数据库获取,登录去除
|
| | | self.maxPlayerCnt = 200
|
| | | self.maxPlayerCnt = config.GetMaxPlayerCnt()
|
| | | self.loginCnt = 0
|
| | | #===========================================================================
|
| | | # def InitDBCon(self):
|
| | | # dbConfig = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath1)
|
| | | # dbConfig.SetSection( "auth" )
|
| | | # self.user = dbConfig.GetValue("logdb_user")
|
| | | # self.pwd = GetEncodePsw(dbConfig.GetValue("logdb_pwd"))[1]
|
| | | # |
| | | # dbConfig2 = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath2)
|
| | | # dbConfig2.SetSection( "connect" )
|
| | | # self.dbIP = dbConfig2.GetValue("LOG_DB_IP")
|
| | | # self.connection = pymongo.Connection(self.dbIP, 27017, auto_start_request=False)
|
| | | # db = self.connection.admin
|
| | | # if not db.authenticate(self.user, self.pwd):
|
| | | # logging.error( "!!!InitDBCon error" )
|
| | | # return
|
| | | # |
| | | # #print dbConfig2.GetValue("LOG_DB_NAME"), "--------------"
|
| | | # |
| | | # self.logdb = self.connection[dbConfig2.GetValue("LOG_DB_NAME")]
|
| | | # #self.interfaceDatadb = self.connection[dbConfig2.GetValue("INTERFACE_DB_NAME")]
|
| | | # self.userdb = self.connection[dbConfig2.GetValue("USER_DB_NAME")]
|
| | | # |
| | | # logging.info("conn ok-----------")
|
| | | #===========================================================================
|
| | | self.AccountSource = config.GetAccountSource()
|
| | | |
| | | def InitDBCon(self):
|
| | | dbConfig = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath1)
|
| | | dbConfig.SetSection( "auth" )
|
| | | self.user = dbConfig.GetValue("userdb_user")
|
| | | self.pwd = GetEncodePsw(dbConfig.GetValue("userdb_pwd"))[1]
|
| | | |
| | | dbConfig2 = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath2)
|
| | | dbConfig2.SetSection( "connect" )
|
| | | self.dbIP = dbConfig2.GetValue("USER_DB_IP")
|
| | | self.connection = pymongo.Connection(self.dbIP, 27017, auto_start_request=False)
|
| | | db = self.connection.admin
|
| | | if not db.authenticate(self.user, self.pwd):
|
| | | logging.error( "!!!InitDBCon error" )
|
| | | return
|
| | | |
| | | self.userdb = self.connection[dbConfig2.GetValue("USER_DB_NAME")]
|
| | | |
| | | logging.info("conn ok-----------")
|
| | |
|
| | | # 1.获取脱机挂玩家数据--GameLog
|
| | | def GetTJGRobot(self):
|
| | | index = 0
|
| | | if len(sys.argv) == 2:
|
| | | index = sys.argv[1]
|
| | | clientMac = "abc"
|
| | | for i in xrange(self.maxPlayerCnt):
|
| | | accID = "ice%s_%s@yun@s1"%(index, i)
|
| | |
|
| | | account = ("123456789012345678901234567890ab", accID, clientMac, 1)
|
| | | if account not in self.tokenList:
|
| | | self.tokenList.append(account)
|
| | | if self.AccountSource == 0:
|
| | | index = 0
|
| | | if len(sys.argv) == 2:
|
| | | index = sys.argv[1]
|
| | | clientMac = "abc"
|
| | | for i in xrange(self.maxPlayerCnt):
|
| | | accID = "ice%s_%s@yun@s1"%(index, i)
|
| | | |
| | | account = ("123456789012345678901234567890ab", accID, clientMac, 1)
|
| | | if account not in self.tokenList:
|
| | | self.tokenList.append(account)
|
| | | else:
|
| | | col = self.userdb["tagDSAccount"]
|
| | | account = None
|
| | | for rec in col.find(limit=self.maxPlayerCnt):
|
| | | account = ("123456789012345678901234567890ab", str(rec['ACCID']), 'anc', 1)
|
| | | if account not in self.tokenList:
|
| | | self.tokenList.append(account)
|
| | |
|
| | | |
| | | print account
|
| | | if self.tokenList:
|
| | | logging.info( "待登录的脱机挂玩家----:%s"%(len(self.tokenList)))
|
| | | #logging.debug( "待登录的脱机挂玩家----tokenList:%s"%(self.tokenList))
|
| | |
| | | def GetTokenList(self):
|
| | | return self.tokenList
|
| | |
|
| | | def AddCrossRobotInfo(self, accID, IPList):
|
| | | account = ("123456789012345678901234567890ab", accID, "abc", 1, IPList)
|
| | | if account not in self.tokenList:
|
| | | self.tokenList.append(account)
|
| | | |
| | | def RemoveToken(self, value):
|
| | | self.tokenList.remove(value)
|
| | |
|