本文整理汇总了C++中Network::connectToServer方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::connectToServer方法的具体用法?C++ Network::connectToServer怎么用?C++ Network::connectToServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::connectToServer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
device->getGUIEnvironment()->getSkin()->setFont(font);
}
//Choose scenario
std::string scenarioName = "";
std::string hostname = "";
bool secondary = false;
ScenarioChoice scenarioChoice(device,&language);
scenarioChoice.chooseScenario(scenarioName, hostname, secondary);
u32 creditsStartTime = device->getTimer()->getRealTime();
//std::cout << "Chosen " << scenarioName << " with " << hostname << std::endl;
//seed random number generator
std::srand(device->getTimer()->getTime());
//create GUI
GUIMain guiMain(device, &language);
//Create simulation model
SimulationModel model(device, smgr, &guiMain, scenarioName, secondary);
//load realistic water
//RealisticWaterSceneNode* realisticWater = new RealisticWaterSceneNode(smgr, 4000, 4000, "./",irr::core::dimension2du(512, 512),smgr->getRootSceneNode());
//create event receiver, linked to model
MyEventReceiver receiver(device, &model, &guiMain, portJoystickAxis, stbdJoystickAxis, rudderJoystickAxis);
device->setEventReceiver(&receiver);
//Create networking, linked to model, choosing whether to use main or secondary network mode
Network* network = Network::createNetwork(&model, secondary);
//Network network(&model);
network->connectToServer(hostname);
//create NMEA serial port, linked to model
NMEA nmea(&model, serialPortName);
//check enough time has elapsed to show the credits screen (15s)
while(device->getTimer()->getRealTime() - creditsStartTime < 15000) {
device->sleep(100);
}
//set up timing for NMEA: FIXME: Make this a defined constant
u32 nextNMEATime = device->getTimer()->getTime()+250;
//main loop
while(device->run())
{
network->update();
//Check if time has elapsed, so we send data once per second.
if (device->getTimer()->getTime() >= nextNMEATime) {
nmea.updateNMEA();
nmea.sendNMEASerial();
nextNMEATime = device->getTimer()->getTime()+250; //Fixme: Make this a defined constant.
}
model.update();
//Set up
driver->setViewPort(core::rect<s32>(0,0,graphicsWidth,graphicsHeight)); //Full screen before beginScene
driver->beginScene(true,true,video::SColor(255,100,101,140));
//3d view portion