//------------------------------------------------------------------------------------- void PyGC::set_debug(uint32 flsgs) { PyObject* pyRet = PyObject_CallFunction(set_debugMethod_, const_cast<char*>("i"), flsgs); SCRIPT_ERROR_CHECK(); if(pyRet) { S_RELEASE(pyRet); } }
//------------------------------------------------------------------------------------- int Script::run_simpleString(std::string command, std::string* retBufferPtr) { if(retBufferPtr != NULL) { if(!pyStdouterrHook_->install()){ ERROR_MSG("Script::Run_SimpleString::pyStdouterrHook_->install() is failed!\n"); SCRIPT_ERROR_CHECK(); return -1; } pyStdouterrHook_->setHookBuffer(retBufferPtr); PyRun_SimpleString(command.c_str()); SCRIPT_ERROR_CHECK(); // 检查是否有错误产生 pyStdouterrHook_->uninstall(); return 0; } PyRun_SimpleString(command.c_str()); SCRIPT_ERROR_CHECK(); // 检查是否有错误产生 return 0; }
//------------------------------------------------------------------------------------- int32 Proxy::onLogOnAttempt(const char* addr, uint32 port, const char* password) { PyObject* pyResult = PyObject_CallMethod(this, const_cast<char*>("onLogOnAttempt"), const_cast<char*>("uku"), PyUnicode_FromString(addr), PyLong_FromLong(port), PyUnicode_FromString(password) ); int32 ret = LOG_ON_REJECT; if(pyResult != NULL) { ret = PyLong_AsLong(pyResult); SCRIPT_ERROR_CHECK(); Py_DECREF(pyResult); } else SCRIPT_ERROR_CHECK(); return ret; }
//------------------------------------------------------------------------------------- client::Entity* ClientObjectBase::createEntityCommon(const char* entityType, PyObject* params, bool isInitializeScript, ENTITY_ID eid, bool initProperty, EntityMailbox* base, EntityMailbox* cell) { KBE_ASSERT(eid > 0); ScriptDefModule* sm = EntityDef::findScriptModule(entityType); if(sm == NULL) { PyErr_Format(PyExc_TypeError, "ClientObjectBase::createEntityCommon: entity [%s] not found.\n", entityType); PyErr_PrintEx(0); return NULL; } else if(!sm->hasClient()) { PyErr_Format(PyExc_TypeError, "ClientObjectBase::createEntityCommon: entity [%s] not found.\n", entityType); PyErr_PrintEx(0); return NULL; } PyObject* obj = sm->createObject(); client::Entity* entity = new(obj) client::Entity(eid, sm, base, cell); entity->pClientApp(this); if(initProperty) entity->initProperty(); // 将entity加入entities pEntities_->add(eid, entity); // 初始化脚本 if(isInitializeScript) entity->initializeEntity(params); SCRIPT_ERROR_CHECK(); if(g_debugEntity) { INFO_MSG(boost::format("ClientObjectBase::createEntityCommon: new %1% (%2%) refc=%3%.\n") % entityType % eid % obj->ob_refcnt); } else { INFO_MSG(boost::format("ClientObjectBase::createEntityCommon: new %1% (%2%)\n") % entityType % eid); } EventData_CreatedEntity eventdata; eventdata.pEntity = entity->getAspect(); eventHandler_.fire(&eventdata); return entity; }
virtual void handleTimeout(TimerHandle handle, void * pUser) { int id = ScriptTimersUtil::getIDForHandle(scriptTimers_, handle); PyObject *pyRet = PyObject_CallFunction(pyCallback_, "i", id); if (pyRet == NULL) { SCRIPT_ERROR_CHECK(); return; } return; }
//------------------------------------------------------------------------------------- PyObject* Copy::deepcopy(PyObject* pyobj) { PyObject* pyRet = PyObject_CallFunction(deepcopyMethod_, const_cast<char*>("(O)"), pyobj); if(!pyRet) { SCRIPT_ERROR_CHECK(); Py_RETURN_NONE; } return pyRet; }
//------------------------------------------------------------------------------------- PyObject* PyStruct::unpack(PyObject* fmt, PyObject* args) { PyObject* pyRet = PyObject_CallFunction(unpack_, const_cast<char*>("(OO)"), fmt, args); if (!pyRet) { ERROR_MSG("PyStruct::unpack: is failed.\n"); } SCRIPT_ERROR_CHECK(); return pyRet; }
//------------------------------------------------------------------------------------- int32 Proxy::onLogOnAttempt(const char* addr, uint32 port, const char* password) { SCOPED_PROFILE(SCRIPTCALL_PROFILE); PyObject* pyResult = PyObject_CallMethod(this, const_cast<char*>("onLogOnAttempt"), const_cast<char*>("sks"), addr, port, password ); int32 ret = LOG_ON_REJECT; if(pyResult != NULL) { ret = PyLong_AsLong(pyResult); SCRIPT_ERROR_CHECK(); Py_DECREF(pyResult); } else SCRIPT_ERROR_CHECK(); return ret; }
//------------------------------------------------------------------------------------- void Blob::initialize(PyObject* pyBytesInitData) { char *buffer; Py_ssize_t length; if(PyBytes_AsStringAndSize(pyBytesInitData, &buffer, &length) < 0) { SCRIPT_ERROR_CHECK(); return; } if(length > 0) stream_.append(buffer, length); }
//------------------------------------------------------------------------------------- bool ClientApp::installPyModules() { registerScript(client::Entity::getScriptType()); onInstallPyModules(); // 注册设置脚本输出类型 APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), scriptLogType, __py_setScriptLogType, METH_VARARGS, 0) if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_NORMAL", log4cxx::ScriptLevel::SCRIPT_INT)) { ERROR_MSG( "ClientApp::installPyModules: Unable to set KBEngine.LOG_TYPE_NORMAL.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_INFO", log4cxx::ScriptLevel::SCRIPT_INFO)) { ERROR_MSG( "ClientApp::installPyModules: Unable to set KBEngine.LOG_TYPE_INFO.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_ERR", log4cxx::ScriptLevel::SCRIPT_ERR)) { ERROR_MSG( "ClientApp::installPyModules: Unable to set KBEngine.LOG_TYPE_ERR.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_DBG", log4cxx::ScriptLevel::SCRIPT_DBG)) { ERROR_MSG( "ClientApp::installPyModules: Unable to set KBEngine.LOG_TYPE_DBG.\n"); } if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_WAR", log4cxx::ScriptLevel::SCRIPT_WAR)) { ERROR_MSG( "ClientApp::installPyModules: Unable to set KBEngine.LOG_TYPE_WAR.\n"); } registerPyObjectToScript("entities", pEntities_); // 安装入口模块 PyObject *entryScriptFileName = PyUnicode_FromString(g_kbeConfig.entryScriptFile()); if(entryScriptFileName != NULL) { entryScript_ = PyImport_Import(entryScriptFileName); SCRIPT_ERROR_CHECK(); S_RELEASE(entryScriptFileName); if(entryScript_.get() == NULL) { return false; } } return true; }
//------------------------------------------------------------------------------------- PyObject* Pickler::unpickle(const std::string& str) { PyObject* pyRet = PyObject_CallFunction(unPicklerMethod_, const_cast<char*>("(y#)"), str.data(), str.length()); if (!pyRet) { ERROR_MSG(fmt::format("Pickler::unpickle: failed to unpickle[{}] len={}.\n", str.c_str(), str.length())); } SCRIPT_ERROR_CHECK(); return pyRet; }
//------------------------------------------------------------------------------------- bool PyProfile::start(std::string profile) { PyProfile::PROFILES::iterator iter = profiles_.find(profile); if(iter != profiles_.end()) { ERROR_MSG(boost::format("PyProfile::start: profile(%1%) already exists!\n") % profile); return false; } PyObject* pyRet = PyObject_CallFunction(profileMethod_, const_cast<char*>("")); if(!pyRet) { SCRIPT_ERROR_CHECK(); return false; } PyObject* pyRet1 = PyObject_CallMethod(pyRet, const_cast<char*>("enable"), const_cast<char*>("")); if(!pyRet1) { SCRIPT_ERROR_CHECK(); Py_DECREF(pyRet); return false; } Py_DECREF(pyRet1); profiles_[profile] = pyRet; char buf[MAX_BUF]; kbe_snprintf(buf, MAX_BUF, "print(\"PyProfile::start: profile=%s.\")", profile.c_str()); pScript_->run_simpleString(buf, NULL); return true; }
//------------------------------------------------------------------------------------- void PyProfile::addToStream(std::string profile, MemoryStream* s) { PyProfile::PROFILES::iterator iter = profiles_.find(profile); if(iter == profiles_.end()) { ERROR_MSG(boost::format("PyProfile::getstats: profile(%1%) is not exists!\n") % profile); return; } if(!pScript_->pyStdouterrHook()->install()){ ERROR_MSG("PyProfile::addToStream: pyStdouterrHook_->install() is failed!\n"); SCRIPT_ERROR_CHECK(); return; } std::string retBufferPtr; pScript_->pyStdouterrHook()->setHookBuffer(&retBufferPtr); pScript_->pyStdouterrHook()->setPrint(false); PyObject* pyRet = PyObject_CallMethod(iter->second.get(), const_cast<char*>("print_stats"), const_cast<char*>("s"), const_cast<char*>("time")); pScript_->pyStdouterrHook()->setPrint(true); pScript_->pyStdouterrHook()->uninstall(); SCRIPT_ERROR_CHECK(); if(!pyRet) { return; } (*s) << retBufferPtr; // DEBUG_MSG(boost::format("PyProfile::addToStream:%1%") % retBufferPtr); Py_DECREF(pyRet); }
//------------------------------------------------------------------------------------- void Loginapp::onReqCreateAccountResult(Network::Channel* pChannel, MemoryStream& s) { SERVER_ERROR_CODE failedcode; std::string accountName; std::string password; std::string retdatas = ""; s >> failedcode >> accountName >> password; s.readBlob(retdatas); // 把请求交由脚本处理 SCOPED_PROFILE(SCRIPTCALL_PROFILE); PyObject* pyResult = PyObject_CallMethod(getEntryScript().get(), const_cast<char*>("onCreateAccountCallbackFromDB"), const_cast<char*>("sHy#"), accountName.c_str(), failedcode, retdatas.c_str(), retdatas.length()); if(pyResult != NULL) { Py_DECREF(pyResult); } else { SCRIPT_ERROR_CHECK(); } DEBUG_MSG(fmt::format("Loginapp::onReqCreateAccountResult: accountName={}, failedcode={}.\n", accountName.c_str(), failedcode)); PendingLoginMgr::PLInfos* ptinfos = pendingCreateMgr_.remove(accountName); if(ptinfos == NULL) return; Network::Channel* pClientChannel = this->networkInterface().findChannel(ptinfos->addr); if(pClientChannel == NULL) return; pClientChannel->extra(""); Network::Bundle* pBundle = Network::Bundle::createPoolObject(); (*pBundle).newMessage(ClientInterface::onCreateAccountResult); (*pBundle) << failedcode; (*pBundle).appendBlob(retdatas); pClientChannel->send(pBundle); SAFE_RELEASE(ptinfos); }
//------------------------------------------------------------------------------------- void Entity::onRemoteMethodCall(Mercury::Channel* pChannel, MemoryStream& s) { SCOPED_PROFILE(SCRIPTCALL_PROFILE); if(isDestroyed()) { ERROR_MSG(boost::format("%1%::onRemoteMethodCall: %2% is destroyed!\n") % getScriptName() % getID()); s.read_skip(s.opsize()); return; } ENTITY_METHOD_UID utype = 0; s >> utype; DEBUG_MSG(boost::format("Entity::onRemoteMethodCall: entityID %1%, methodType %2%.\n") % id_ % utype); MethodDescription* md = scriptModule_->findCellMethodDescription(utype); if(md == NULL) { ERROR_MSG(boost::format("Entity::onRemoteMethodCall: can't found method. utype=%1%, callerID:%2%.\n") % utype % id_); return; } md->currCallerID(this->getID()); PyObject* pyFunc = PyObject_GetAttrString(this, const_cast<char*> (md->getName())); if(md != NULL) { PyObject* pyargs = md->createFromStream(&s); if(pyargs) { md->call(pyFunc, pyargs); Py_XDECREF(pyargs); } else { SCRIPT_ERROR_CHECK(); } } Py_XDECREF(pyFunc); }
//------------------------------------------------------------------------------------- void PyProfile::print_stats(const std::string& sort, const std::string& profileName) { PyProfile::PROFILES::iterator iter = profiles_.find(profileName.c_str()); if(iter == profiles_.end()) { return; } PyObject* pyRet = PyObject_CallMethod(iter->second.get(), const_cast<char*>("print_stats"), const_cast<char*>("s"), const_cast<char*>(sort.c_str())); if(pyRet) Py_DECREF(pyRet); else SCRIPT_ERROR_CHECK(); }
void EntityApp<E>::reloadScript(bool fullReload) { EntityDef::reload(fullReload); onReloadScript(fullReload); // 所有脚本都加载完毕 PyObject* pyResult = PyObject_CallMethod(getEntryScript().get(), const_cast<char*>("onInit"), const_cast<char*>("i"), 1); if(pyResult != NULL) Py_DECREF(pyResult); else SCRIPT_ERROR_CHECK(); }
//------------------------------------------------------------------------------------- void Baseapp::_onCreateBaseAnywhereCallback(Mercury::Channel* pChannel, CALLBACK_ID callbackID, std::string& entityType, ENTITY_ID eid, COMPONENT_ID componentID) { if(callbackID == 0) return; PyObjectPtr pyCallback = callbackMgr().take(callbackID); PyObject* pyargs = PyTuple_New(1); if(pChannel != NULL) { ScriptDefModule* sm = EntityDef::findScriptModule(entityType.c_str()); if(sm == NULL) { ERROR_MSG("Baseapp::onCreateBaseAnywhereCallback: can't found entityType:%s.\n", entityType.c_str()); Py_DECREF(pyargs); return; } // 如果entity属于另一个baseapp创建则设置它的mailbox Mercury::Channel* pOtherBaseappChannel = Components::getSingleton().findComponent(componentID)->pChannel; KBE_ASSERT(pOtherBaseappChannel != NULL); PyObject* mb = static_cast<EntityMailbox*>(new EntityMailbox(sm, NULL, componentID, eid, MAILBOX_TYPE_BASE)); PyTuple_SET_ITEM(pyargs, 0, mb); PyObject_CallObject(pyCallback.get(), pyargs); //Py_DECREF(mb); int i=0; i++; } else { Base* base = pEntities_->find(eid); if(base == NULL) { ERROR_MSG("Baseapp::onCreateBaseAnywhereCallback: can't found entity:%ld.\n", eid); Py_DECREF(pyargs); return; } Py_INCREF(base); PyTuple_SET_ITEM(pyargs, 0, base); PyObject_CallObject(pyCallback.get(), pyargs); } SCRIPT_ERROR_CHECK(); Py_DECREF(pyargs); }
//------------------------------------------------------------------------------------- void Interfaces::reqCreateAccount(Network::Channel* pChannel, KBEngine::MemoryStream& s) { std::string registerName, accountName, password, datas; COMPONENT_ID cid; uint8 accountType = 0; s >> cid >> registerName >> password >> accountType; s.readBlob(datas); if(accountType == (uint8)ACCOUNT_TYPE_MAIL) { } REQCREATE_MAP::iterator iter = reqCreateAccount_requests_.find(registerName); if(iter != reqCreateAccount_requests_.end()) { return; } CreateAccountTask* pinfo = new CreateAccountTask(); pinfo->commitName = registerName; pinfo->accountName = registerName; pinfo->getDatas = ""; pinfo->password = password; pinfo->postDatas = datas; pinfo->retcode = SERVER_ERR_OP_FAILED; pinfo->baseappID = cid; pinfo->dbmgrID = pChannel->componentID(); pinfo->address = pChannel->addr(); pinfo->enable = true; reqCreateAccount_requests_[pinfo->commitName] = pinfo; // 把请求交由脚本处理 SCOPED_PROFILE(SCRIPTCALL_PROFILE); PyObject* pyResult = PyObject_CallMethod(getEntryScript().get(), const_cast<char*>("onRequestCreateAccount"), const_cast<char*>("ssy#"), registerName.c_str(), password.c_str(), datas.c_str(), datas.length()); if(pyResult != NULL) Py_DECREF(pyResult); else SCRIPT_ERROR_CHECK(); }
//------------------------------------------------------------------------------------- void TelnetHandler::processPythonCommand(std::string command) { if(pTelnetServer_->pScript() == NULL || command.size() == 0) return; command += "\n"; PyObject* pycmd = PyUnicode_DecodeUTF8(command.data(), command.size(), NULL); if(pycmd == NULL) { SCRIPT_ERROR_CHECK(); return; } DEBUG_MSG(fmt::format("TelnetHandler::processPythonCommand: size({}), command={}.\n", command.size(), command)); std::string retbuf = ""; PyObject* pycmd1 = PyUnicode_AsEncodedString(pycmd, "utf-8", NULL); pTelnetServer_->pScript()->run_simpleString(PyBytes_AsString(pycmd1), &retbuf); // 把返回值中的'\n'替換成'\r\n',以解决在vt100终端中显示不正确的问题 std::string::size_type pos = 0; while ((pos = retbuf.find('\n', pos)) != std::string::npos) { if (retbuf[pos - 1] != '\r') { retbuf.insert(pos, "\r"); pos++; } pos++; } if(retbuf.size() > 0) { // 将结果返回给客户端 Network::Bundle* pBundle = Network::Bundle::createPoolObject(); (*pBundle) << retbuf; pEndPoint_->send(pBundle); Network::Bundle::reclaimPoolObject(pBundle); sendEnter(); } Py_DECREF(pycmd); Py_DECREF(pycmd1); }
//------------------------------------------------------------------------------------- void ScriptCallbackHandler::handleTimeout( TimerHandle handle, void * pUser ) { AUTO_SCOPED_PROFILE("callCallbacks"); //int id = scriptCallbacks_.getIDForHandle(handle); PyObject * pObject = pObject_; Py_INCREF( pObject ); PyObject * pResult = PyObject_CallFunction( pObject, const_cast<char*>("")); Py_XDECREF( pResult ); Py_DECREF( pObject ); SCRIPT_ERROR_CHECK(); }
//------------------------------------------------------------------------------------- PyObject* MethodDescription::call(PyObject* func, PyObject* args) { PyObject* pyResult = NULL; if (!PyCallable_Check(func)) { PyErr_Format(PyExc_TypeError, "MethodDescription::call: Script[%s] call attempted on a error object!", getName()); } else { if(checkArgs(args)) pyResult = PyObject_CallObject(func, args); } SCRIPT_ERROR_CHECK(); return pyResult; }
//------------------------------------------------------------------------------------- std::string Pickler::pickle(PyObject* pyobj, int8 protocol) { PyObject* pyRet = PyObject_CallFunction(picklerMethod_, const_cast<char*>("(Oi)"), pyobj, protocol); SCRIPT_ERROR_CHECK(); if(pyRet) { std::string str; str.assign(PyBytes_AsString(pyRet), PyBytes_Size(pyRet)); S_RELEASE(pyRet); return str; } return ""; }
//------------------------------------------------------------------------------------- void PythonApp::reloadScript(bool fullReload) { onReloadScript(fullReload); // SCOPED_PROFILE(SCRIPTCALL_PROFILE); // 所有脚本都加载完毕 PyObject* pyResult = PyObject_CallMethod(getEntryScript().get(), const_cast<char*>("onInit"), const_cast<char*>("i"), 1); if(pyResult != NULL) Py_DECREF(pyResult); else SCRIPT_ERROR_CHECK(); }
//------------------------------------------------------------------------------------- void ClientApp::onTargetChanged() { // 所有脚本都加载完毕 PyObject* pyResult = PyObject_CallMethod(getEntryScript().get(), const_cast<char*>("onTargetChanged"), const_cast<char*>("i"), targetID_); if(pyResult != NULL) { Py_DECREF(pyResult); } else { SCRIPT_ERROR_CHECK(); } }
//------------------------------------------------------------------------------------- void Interfaces::charge(Network::Channel* pChannel, KBEngine::MemoryStream& s) { OrdersCharge* pOrdersCharge = new OrdersCharge(); pOrdersCharge->timeout = timestamp() + uint64(g_kbeSrvConfig.interfaces_orders_timeout_ * stampsPerSecond()); pOrdersCharge->dbmgrID = pChannel->componentID(); pOrdersCharge->address = pChannel->addr(); s >> pOrdersCharge->baseappID; s >> pOrdersCharge->ordersID; s >> pOrdersCharge->dbid; s.readBlob(pOrdersCharge->postDatas); s >> pOrdersCharge->cbid; INFO_MSG(fmt::format("Interfaces::charge: componentID={4}, chargeID={0}, dbid={1}, cbid={2}, datas={3}!\n", pOrdersCharge->ordersID, pOrdersCharge->dbid, pOrdersCharge->cbid, pOrdersCharge->postDatas, pOrdersCharge->baseappID)); ORDERS::iterator iter = orders_.find(pOrdersCharge->ordersID); if(iter != orders_.end()) { ERROR_MSG(fmt::format("Interfaces::charge: chargeID={} is exist!\n", pOrdersCharge->ordersID)); delete pOrdersCharge; return; } ChargeTask* pinfo = new ChargeTask(); pinfo->orders = *pOrdersCharge; pinfo->pOrders = pOrdersCharge; orders_[pOrdersCharge->ordersID].reset(pOrdersCharge); // 把请求交由脚本处理 SCOPED_PROFILE(SCRIPTCALL_PROFILE); PyObject* pyResult = PyObject_CallMethod(getEntryScript().get(), const_cast<char*>("onRequestCharge"), const_cast<char*>("sKy#"), pOrdersCharge->ordersID.c_str(), pOrdersCharge->dbid, pOrdersCharge->postDatas.c_str(), pOrdersCharge->postDatas.length()); if(pyResult != NULL) Py_DECREF(pyResult); else SCRIPT_ERROR_CHECK(); }
//------------------------------------------------------------------------------------- void PyFileDescriptor::callback() { if(pyCallback_ != NULL) { PyObject* pyResult = PyObject_CallFunction(pyCallback_.get(), const_cast<char*>("i"), fd_); if(pyResult != NULL) Py_DECREF(pyResult); else SCRIPT_ERROR_CHECK(); } else { ERROR_MSG(boost::format("PyFileDescriptor::callback: can't found callback:%1%.\n") % fd_); } }
//------------------------------------------------------------------------------------- StringDataDownload::StringDataDownload(PyObjectPtr objptr, const std::string & descr, int16 id): DataDownload(objptr, descr, id) { PyObject* pyobj = PyUnicode_AsUTF8String(objptr.get()); if(pyobj == NULL) { SCRIPT_ERROR_CHECK(); error_ = true; } else { totalBytes_ = (uint32)PyBytes_GET_SIZE(pyobj); stream_ = new char[totalBytes_ + 1]; memcpy(getOutStream(), PyBytes_AS_STRING(pyobj), totalBytes_); Py_DECREF(pyobj); } }
//------------------------------------------------------------------------------------- bool Dbmgr::initializeEnd() { // 添加一个timer, 每秒检查一些状态 loopCheckTimerHandle_ = this->dispatcher().addTimer(1000000, this, reinterpret_cast<void *>(TIMEOUT_CHECK_STATUS)); mainProcessTimer_ = this->dispatcher().addTimer(1000000 / 50, this, reinterpret_cast<void *>(TIMEOUT_TICK)); // 添加globalData, baseAppData, cellAppData支持 pGlobalData_ = new GlobalDataServer(GlobalDataServer::GLOBAL_DATA); pBaseAppData_ = new GlobalDataServer(GlobalDataServer::BASEAPP_DATA); pCellAppData_ = new GlobalDataServer(GlobalDataServer::CELLAPP_DATA); pGlobalData_->addConcernComponentType(CELLAPP_TYPE); pGlobalData_->addConcernComponentType(BASEAPP_TYPE); pBaseAppData_->addConcernComponentType(BASEAPP_TYPE); pCellAppData_->addConcernComponentType(CELLAPP_TYPE); INFO_MSG(fmt::format("Dbmgr::initializeEnd: digest({})\n", EntityDef::md5().getDigestStr())); SCOPED_PROFILE(SCRIPTCALL_PROFILE); // 所有脚本都加载完毕 PyObject* pyResult = PyObject_CallMethod(getEntryScript().get(), const_cast<char*>("onDBMgrReady"), const_cast<char*>("")); if(pyResult != NULL) Py_DECREF(pyResult); else SCRIPT_ERROR_CHECK(); pTelnetServer_ = new TelnetServer(&this->dispatcher(), &this->networkInterface()); pTelnetServer_->pScript(&this->getScript()); bool ret = pTelnetServer_->start(g_kbeSrvConfig.getDBMgr().telnet_passwd, g_kbeSrvConfig.getDBMgr().telnet_deflayer, g_kbeSrvConfig.getDBMgr().telnet_port); Components::getSingleton().extraData4(pTelnetServer_->port()); return ret && initInterfacesHandler() && initDB(); }
//------------------------------------------------------------------------------------- PyObject* Interfaces::__py_accountLoginResponse(PyObject* self, PyObject* args) { const char *commitName; const char *realAccountName; char *extraDatas = NULL; Py_ssize_t extraDatas_size = 0; KBEngine::SERVER_ERROR_CODE errCode; if (!PyArg_ParseTuple(args, "ssy#H", &commitName, &realAccountName, &extraDatas, &extraDatas_size, &errCode)) return NULL; Interfaces::getSingleton().accountLoginResponse(std::string(commitName), std::string(realAccountName), (extraDatas && extraDatas_size > 0) ? std::string(extraDatas, extraDatas_size) : std::string(""), errCode); SCRIPT_ERROR_CHECK(); S_Return; }