Esempio n. 1
0
	def _get_uniqid_cb(self, data, params):
		params = json.loads(params)
		
		save_data = {key: str(value) for key, value in params.items() if key in self._column_list}
		print "save_data:", save_data
		
		if not data:  # 没有数据,插入
			sql = Interface.join_insert_sql(self.table, save_data)
			print "insert sql:",sql
			SqlExec.SqlExec(sql)
			
			sql = Interface.join_get_sql(self.table, self.uid, params[self.uid])
			SqlExec.SqlExec(sql, self._get_uniqid_cb2, json.dumps(params))
			
		else:  # 有数据,更新
			self._get_uniqid_cb2(data, json.dumps(params))
Esempio n. 2
0
	def user_check(self, sockfd, params):
		"""根据发给客户端的uniqid判断有没有player"""
		if self.uid not in params:
			
			return
		uid = params[self.uid]
		uniqid = params['id']
		clientproxy = self._account_list.get(uid)
		if not clientproxy:
			return
		
		sql = Interface.join_get_sql("player", 'id', uniqid)
		
		SqlExec.SqlExec(sql, self._check_user_cb, json.dumps(params))
Esempio n. 3
0
	def login_account(self, sockfd, params):
		"""一般作为客户端第一条协议"""
		# 条件判断
		
		# 判断成功
		if self.uid not in params:
			
			return
		uid = params[self.uid]
		clientproxy = ClientProxy(sockfd)
		self[uid] = clientproxy
		
		sql = Interface.join_get_sql(self.table, self.uid, uid)
		print "sql:",sql
		
		SqlExec.SqlExec(sql, self._get_uniqid_cb, json.dumps(params))
Esempio n. 4
0
def OnConnector(command_id, sub_id, data):
    """游戏服作为客户端连接的服务器返回的数据"""
    Logger.LogDebug("OnConnector: %d,%d,%s" % (command_id, sub_id, data))

    dict = None

    try:
        dict = json.loads(data)
        print dict.keys()
    except:
        import traceback
        traceback.print_exc()

    if dict is None:
        Logger.LogError("CallMethod Error: dict is None:%d,%d" %
                        (command_id, sub_id, data))
        return

    from common import SqlExec
    SqlExec.OnExecCallback(sub_id, dict)

    return 0, "success"
Esempio n. 5
0
 def queryDb(self, callback):
     Logger.LogDebug("saveobj.querydb:%s" % self.getSqlSelect())
     func = lambda data: self.loadFromDb(data, callback)
     SqlExec.SqlExec(self.getSqlSelect(), func)
Esempio n. 6
0
 def createDb(self):
     SqlExec.SqlExec(self.getSqlInsert())
Esempio n. 7
0
 def _saveToDb(self):
     Logger.LogDebug("saveobj.saveToDb:%s" % self.getSqlUpdate())
     self._dirty = False
     SqlExec.SqlExec(self.getSqlUpdate())
Esempio n. 8
0
 def _saveToDb(self):
     self._dirty = False
     SqlExec.SqlExec(self.getSqlUpdate())
     print self.getSqlUpdate()