Skip to content
Browse files

Merge pull request #75 from 1958/master

merge
  • Loading branch information...
2 parents 9a8465a + 2290a09 commit db36a1930e95f5054eca6188183b6ea01ffacf6a @kbengine committed Jul 24, 2014
View
12 kbe/res/server/kbengine_defs.xml
@@ -673,6 +673,18 @@
-->
<account_name_suffix_inc> 0 </account_name_suffix_inc><!-- Type: Integer -->
</account_infos>
+
+ <!-- Telnet服务, 如果端口被占用则向后尝试51001..
+ (Telnet service, if the port is occupied backwards to try 51001)
+ -->
+ <telnet_service>
+ <port> 51000 </port>
+ <password> kbe </password>
+ <!-- 命令默认层
+ (layer of default the command)
+ -->
+ <default_layer> python </default_layer>
+ </telnet_service>
</bots>
<messagelog>
View
22 kbe/src/lib/server/serverconfig.cpp
@@ -997,6 +997,28 @@ bool ServerConfig::loadConfig(std::string fileName)
if(node != NULL){
_botsInfo.tcp_SOMAXCONN = xml->getValInt(node);
}
+
+ node = xml->enterNode(rootNode, "telnet_service");
+ if(node != NULL)
+ {
+ TiXmlNode* childnode = xml->enterNode(node, "port");
+ if(childnode)
+ {
+ _botsInfo.telnet_port = xml->getValInt(childnode);
+ }
+
+ childnode = xml->enterNode(node, "password");
+ if(childnode)
+ {
+ _botsInfo.telnet_passwd = xml->getValStr(childnode);
+ }
+
+ childnode = xml->enterNode(node, "default_layer");
+ if(childnode)
+ {
+ _botsInfo.telnet_deflayer = xml->getValStr(childnode);
+ }
+ }
}
rootNode = xml->getRootNode("messagelog");
View
18 kbe/src/server/tools/bots/bots.cpp
@@ -20,6 +20,7 @@ along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
#include "pybots.hpp"
#include "bots.hpp"
+#include "server/telnet_server.hpp"
#include "client_lib/entity.hpp"
#include "clientobject.hpp"
#include "bots_interface.hpp"
@@ -52,7 +53,8 @@ reqCreateAndLoginTotalCount_(g_serverConfig.getBots().defaultAddBots_totalCount)
reqCreateAndLoginTickCount_(g_serverConfig.getBots().defaultAddBots_tickCount),
reqCreateAndLoginTickTime_(g_serverConfig.getBots().defaultAddBots_tickTime),
pCreateAndLoginHandler_(NULL),
-pEventPoller_(Mercury::EventPoller::create())
+pEventPoller_(Mercury::EventPoller::create()),
+pTelnetServer_(NULL)
{
KBEngine::Mercury::MessageHandlers::pMainMessageHandlers = &BotsInterface::messageHandlers;
g_pComponentbridge = new Componentbridge(ninterface, componentType, componentID);
@@ -86,6 +88,16 @@ bool Bots::initializeBegin()
//-------------------------------------------------------------------------------------
bool Bots::initializeEnd()
{
+ pTelnetServer_ = new TelnetServer(&getMainDispatcher(), &getNetworkInterface());
+ pTelnetServer_->pScript(&getScript());
+ if(!pTelnetServer_->start(g_serverConfig.getBots().telnet_passwd,
+ g_serverConfig.getBots().telnet_deflayer,
+ g_serverConfig.getBots().telnet_port))
+ {
+ ERROR_MSG("Bots::initialize: initializeEnd is error!\n");
+ return false;
+ }
+
return true;
}
@@ -94,6 +106,10 @@ void Bots::finalise()
{
reqCreateAndLoginTotalCount_ = 0;
SAFE_RELEASE(pCreateAndLoginHandler_);
+
+ pTelnetServer_->stop();
+ SAFE_RELEASE(pTelnetServer_);
+
ClientApp::finalise();
}
View
3 kbe/src/server/tools/bots/bots.hpp
@@ -53,6 +53,7 @@ namespace KBEngine{
class ClientObject;
class PyBots;
+class TelnetServer;
typedef SmartPointer<ClientObject> ClientObjectPtr;
class Bots : public ClientApp
@@ -314,6 +315,8 @@ class Bots : public ClientApp
CreateAndLoginHandler* pCreateAndLoginHandler_;
Mercury::EventPoller* pEventPoller_;
+
+ TelnetServer* pTelnetServer_;
};
}

0 comments on commit db36a19

Please sign in to comment.
Something went wrong with that request. Please try again.