当前位置: 首页>>代码示例>>C++>>正文


C++ Network::connectToServer方法代码示例

本文整理汇总了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
开发者ID:SeawolfRN,项目名称:bc,代码行数:67,代码来源:main.cpp


注:本文中的Network::connectToServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。