Exemple #1
0
//-------------------------------------------------------------------------------------
bool
NetworkManager::connect(const CEGUI::EventArgs&)
{
  CEGUI::WindowManager *winMgr = CEGUI::WindowManager::getSingletonPtr();
  CEGUI::String Iptmp;
  CEGUI::String PortTmp;
  unsigned int i = 1;
  if (winMgr->isWindowPresent("Connect/ContainerGrp/Ip"))
    {
      Iptmp = winMgr->getWindow("Connect/ContainerGrp/Ip")->getText();
      PortTmp = winMgr->getWindow("Connect/ContainerGrp/Port")->getText();
      this->ip_ = std::string(Iptmp.c_str());
      this->port_ = StringToNumber<const char *, int>(PortTmp.c_str());
      zappy::Convert *c = new zappy::Convert();
      zappy::Network::initInstance(this->ip_ , this->port_, *c);
      zappy::Network &p = zappy::Network::getInstance();
      p.setParameters(this->port_, this->ip_);
      p.connect_();
      if (p.isConnected())
	{
	  Thread<zappy::Network> t(p);
	  t.start();
	  while (p.gettingMap() && i < 5000)
	    usleep(++i);
	  this->GfxMgr_->hide("Connect");
	  this->GfxMgr_->createRealScene();
	}
    }
  return true;
}
Exemple #2
0
//-------------------------------------------------------------------------------------
bool
NetworkManager::updateTime(const CEGUI::EventArgs&)
{
  CEGUI::WindowManager *winMgr = CEGUI::WindowManager::getSingletonPtr();
  std::string time;
  std::string s;

  if (winMgr->isWindowPresent("Time/Container/Time"))
    {
      zappy::Network &net = zappy::Network::getInstance();

      time = winMgr->getWindow("Time/Container/Time")->getText().c_str();
      s = "sst " + time + "\n";
      net.setToSend(s);
    }
  return true;
}