FunctionBot::FunctionBot() { m_RawBot = new RawControl(); drive= new RobotDrive(m_RawBot->frontLeft,m_RawBot->backLeft,m_RawBot->frontRight,m_RawBot->backRight); arm = new Timer(); waitTill=0; configDrive(); correct=0; }
//----------------------------------------------------------------------------- Bool ClientNetApplyManager::initialize() { if ( NetManager::initialize() == false ) return false; //mNetDriver = createDriver("Client",1200,false,MG_NET_IOCP_BUFFER_SIZE_CLIENT); mNetDriver = createDriver( "Client", 1200, false, MG_NET_CLIENT_TIMEOUT_TOUCH_TIME, MG_NET_CLIENT_TIMEOUT_DURATION, true, MG_GAME_NET_PACKET_NORMAL_MAX_SIZE, MG_GAME_NET_PACKET_BIG_MAX_SIZE, MG_NET_BUFFER_SIZE_CLIENT, MG_NET_MAX_CLIENT_SOCKET_SENDBUFF_SIZE, MG_NET_MAX_CLIENT_SOCKET_RECVBUFF_SIZE, DRIVER_TYPE_CLIENT); if ( mNetDriver < 0 ) { return false; } GameNetDriveConfig config; config.OnceHandlePacketCount = 1; config.SendCombinePacketMaxSize = 1024*10; config.ReplaceEnableInSendQueue = true; config.ReplaceEnableInRecvQueue = true; config.DiscardEnableInSendQueue = true; config.DiscardEnableInRecvQueue = true; config.BlockWaitEnableInSendQueue = true; config.BlockWaitEnableInRecvQueue = true; configDrive( mNetDriver, config ); return true; }
//----------------------------------------------------------------------------- Bool ServerNetApplyManager::initialize() { if ( GameNetPacketManager::initialize() == false ) return false; SServerSetting& setting = SServerSetting::getInstance(); if ( setting.isClientLisiten() ) { mClientDriver = createDriver( "Client", setting.getClientListenInfo()->maxConnects, false, MG_NET_CLIENT_TIMEOUT_TOUCH_TIME, MG_NET_CLIENT_TIMEOUT_DURATION, true, MG_GAME_NET_PACKET_NORMAL_MAX_SIZE, MG_GAME_NET_PACKET_BIG_MAX_SIZE, MG_NET_BUFFER_SIZE_CLIENT, MG_NET_MAX_CLIENT_SOCKET_SENDBUFF_SIZE, MG_NET_MAX_CLIENT_SOCKET_RECVBUFF_SIZE, DRIVER_TYPE_CLIENT); if ( mClientDriver < 0 ) { return false; } NetAddress addr(setting.getClientListenInfo()->addr); if ( lisiten( mClientDriver, &addr ) == false ) { return false; } GameNetDriveConfig config; config.OnceHandlePacketCount = 1; config.SendCombinePacketMaxSize = 1024*10; config.ReplaceEnableInSendQueue = true; config.ReplaceEnableInRecvQueue = true; config.DiscardEnableInSendQueue = true; config.DiscardEnableInRecvQueue = true; config.BlockWaitEnableInSendQueue = true; config.BlockWaitEnableInRecvQueue = true; configDrive( mClientDriver, config ); } if (setting.getServerListenInfo()) { mServerDriver = createDriver( "Server", setting.getServerListenInfo()->maxConnects, false, MG_NET_SERVER_TIMEOUT_TOUCH_TIME, MG_NET_SERVER_TIMEOUT_DURATION, false, MG_GAME_NET_PACKET_NORMAL_MAX_SIZE, MG_GAME_NET_PACKET_BIG_MAX_SIZE, MG_NET_BUFFER_SIZE_SERVER, MG_NET_MAX_SERVER_SOCKET_SENDBUFF_SIZE, MG_NET_MAX_SERVER_SOCKET_RECVBUFF_SIZE, DRIVER_TYPE_SERVER); if (mServerDriver < 0) { return false; } GameNetDriveConfig config; config.OnceHandlePacketCount = -1; config.SendCombinePacketMaxSize = 1024*10; config.ReplaceEnableInSendQueue = false; config.ReplaceEnableInRecvQueue = false; config.DiscardEnableInSendQueue = false; config.DiscardEnableInRecvQueue = false; config.BlockWaitEnableInSendQueue = false; config.BlockWaitEnableInRecvQueue = false; configDrive( mServerDriver, config ); } else { return false; } if (!setting.getCoreInfo()) { return false; } ServerMain::getInstance().addServer(setting.getCoreInfo()->id,-1); if ( setting.isServerLisiten()) { if ( lisiten( mServerDriver,&(setting.getServerListenInfo()->addr) ) == false ) { return false; } mUniqueFlag = setting.getServerListenInfo()->addr.getIP() * ::GetCurrentProcessId(); if (setting.getConnectServers()->maxConnects > 0) { SServerSetting::ConnectionIt it = setting.getConnectServers()->connectServers.begin(); for (; it != setting.getConnectServers()->connectServers.end(); it++) { ConnectRemoteInfo* connectInfo = it->second; I32 netID = connect( mServerDriver, &(connectInfo->addr),true ); } } } // 开启重新连接线程 //Ptr ptr1; mReConnectThread.create(reConnectThread, this); #ifdef _DEBUG Thread::SetThreadName(mReConnectThread.getThreadId(),"ServerNetApplyManager::mReConnectThread"); #endif // _DEBUG return true; }