def onRecv(self, fileno): if self._socket.fileno() == fileno: sock, addr = self._socket.accept() self._clients[sock.fileno()] = (sock, addr) KBEngine.registerReadFileDescriptor(sock.fileno(), self.onRecv) KBEDebug.DEBUG_MSG("Poller::onRecv: new channel[%s/%i]" % (addr, sock.fileno())) else: sock, addr = self._clients.get(fileno, None) if sock is None: return data = sock.recv(2048) if len(data) == 0: KBEDebug.DEBUG_MSG("Poller::onRecv: %s/%i disconnect!" % (addr, sock.fileno())) KBEngine.deregisterReadFileDescriptor(sock.fileno()) sock.close() del self._clients[fileno] return KBEDebug.DEBUG_MSG("Poller::onRecv: %s/%i get data, size=%i" % (addr, sock.fileno(), len(data))) self.processData(sock, data)
def onClientDeath(self): """ KBEngine method. 客户端对应实体已经销毁 """ KBEDebug.DEBUG_MSG("Account[%i].onClientDeath:" % self.id) self.destroy()
def onInit(isReload): """ KBEngine method. 当引擎启动后初始化完所有的脚本后这个接口被调用 @param isReload: 是否是被重写加载脚本后触发的 @type isReload: bool """ KBEDebug.DEBUG_MSG('onInit::isReload:%s' % isReload)
def onLoseChargeCB(ordersID, dbid, success, datas): """ KBEngine method. 有一个不明订单被处理, 可能是超时导致记录被billing 清除, 而又收到第三方充值的处理回调 """ KBEDebug.DEBUG_MSG('onLoseChargeCB: ordersID=%s, dbid=%i, success=%i, datas=%s' % \ (ordersID, dbid, success, datas))
def load_whitelists(): try: import KBEngine import KBEDebug p = './scripts/data/whitelists.txt' if KBEngine.hasRes(p): fs = KBEngine.open(p, 'r') lines = fs.readlines() for line in lines: if line.strip() != '': whitelists.append(int(line.strip())) KBEDebug.DEBUG_MSG("whitelists: {}".format(whitelists)) except: pass
def onBaseAppData(key, value): """ KBEngine method. baseAppData有改变 """ KBEDebug.DEBUG_MSG('onBaseAppData: %s' % key)
def onGlobalDataDel(key): """ KBEngine method. globalData有删除 """ KBEDebug.DEBUG_MSG('onDelGlobalData: %s' % key)
def onGlobalData(key, value): """ KBEngine method. globalData有改变 """ KBEDebug.DEBUG_MSG('onGlobalData: %s' % key)
def onBaseAppDataDel(key): """ KBEngine method. baseAppData有删除 """ KBEDebug.DEBUG_MSG('onBaseAppDataDel: %s' % key)
def onInit(isReload): """ KBEngine method. 当引擎启动后初始化完所有的脚本后这个接口被调用 """ KBEDebug.DEBUG_MSG('onInit::isReload:%s' % isReload)
def onCellAppDataDel(key): """ KBEngine method. cellAppData删除 """ KBEDebug.DEBUG_MSG('onCellAppDataDel: %s' % key)
def onCellAppData(key, value): """ KBEngine method. cellAppData改变 """ KBEDebug.DEBUG_MSG('onCellAppData: %s' % key)
def printCustomClass(self): KBEDebug.DEBUG_MSG("Account[%i].printCustomClass: %s" % (self.id, CustomClass.Get().printf()))
def __init__(self, spellCaster): KBEDebug.DEBUG_MSG("Skill:__init__") self.spellCaster = spellCaster
def conjure(self, spellCaster): KBEDebug.DEBUG_MSG("Skill:conjure")
def __init__(self): KBEDebug.DEBUG_MSG("Lobby:__init__") KBEngine.Base.__init__(self)