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


C++ Server类代码示例

本文整理汇总了C++中Server的典型用法代码示例。如果您正苦于以下问题:C++ Server类的具体用法?C++ Server怎么用?C++ Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ACE_TMAIN

// This is the main driver program for the time and date server.
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  Server<AccountManager_i> server;

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("\n\tBank server\n\n")));

  try
    {
      if (server.init ("Bank",
                       argc,
                       argv) == -1)
        return 1;
      else
        {
          server.run ();
        }
    }
  catch (const CORBA::UserException& userex)
    {
      userex._tao_print_exception ("User Exception");
      return -1;
    }
  catch (const CORBA::SystemException& sysex)
    {
      sysex._tao_print_exception ("System Exception");
      return -1;
    }
  catch (const ::CORBA::Exception &e)
    {
      e._tao_print_exception ("CORBA exception");
      return 1;
    }

  return 0;
}
开发者ID:CCJY,项目名称:ATCD,代码行数:38,代码来源:server.cpp

示例2: checkServerStatus

bool LoginLayerUC::checkServerStatus(const Server &server)
{
	switch (server.server_status())
	{
		//未开启状态
		case 0:
			{
				tm  tm ;  
				time_t  timep = server.open_time()/1000;
				tm  = *localtime(&timep);  
				int  year =  tm.tm_year + 1900;  
				int  month =  tm.tm_mon + 1;  
				int  day =  tm.tm_mday;  
				int  hour= tm.tm_hour;  
				int minute = tm.tm_min;
				int second = tm.tm_sec;

				CCString* sDay = CCString::createWithFormat("%d/%s%d/%s%d-%s%d:%s%d:%s%d", 
					year, month>9?"":"0", month, day>9?"":"0", day, hour>9?"":"0", hour, minute>9?"":"0", minute, second>9?"":"0", minute);

				CCString* pStr = CCString::createWithFormat(GETLANGSTR(2001), sDay->getCString());
				ShowPopTextTip(pStr->getCString());
				return false;
			}break;
		case 4:
			{
				//服务器是维护状态,不连接,给提示
				ShowPopTextTip(GETLANGSTR(1243));
				return false;
			}break;	
	default:
		break;
	}

	return true;
}
开发者ID:54993306,项目名称:Classes,代码行数:36,代码来源:LoginLayerUC.cpp

示例3: sendPage

/*
 * Attempts to send the requested page for the current connection
 */
void sendPage() {

	// Reset the virtual buffer cursor
	uip_conn->appstate.cursor = 0;

	// Start off with an HTTP OK response header and a blank line
	WiServer.println_P(httpOK);
	WiServer.println();

	// Call the application's 'sendPage' function and ask it to
	// generate the requested page content.
	if (!callbackFunc((char*)uip_conn->appstate.request)) {
		// The URL is not recognized by the sketch
		// Reset the cursor and overwrite the HTTP OK header with a 404 message
		uip_conn->appstate.cursor = 0;
		WiServer.println_P(httpNotFound);
		WiServer.println();
#ifdef DEBUG
 		Serial.println("URL Not Found");
#endif // DEBUG
	}
	// Send the 'real' bytes in the buffer
	send();
}
开发者ID:keithpjolley,项目名称:SensorMatic,代码行数:27,代码来源:WiServer.cpp

示例4: getNodes

void AddMetaNodeExecutor::execute_server() {

    int count, id;
    QString name, edgeName;
    float x, y, z;

    *stream >> name;

    Data::Graph * currentGraph = Manager::GraphManager::getInstance()->getActiveGraph();
    QMap<qlonglong, osg::ref_ptr<Data::Node> >* nodes = currentGraph -> getNodes();

    *stream >> x >> y >> z;

    osg::ref_ptr<Data::Node> metaNode = currentGraph->addNode(name, currentGraph->getNodeMetaType(), osg::Vec3(x,y,z));

    *stream >> edgeName;
    *stream >> count;
    QLinkedList<osg::ref_ptr<Data::Node> > * selectedNodes = new QLinkedList<osg::ref_ptr<Data::Node> >();

    for (int i = 0; i < count; i++) {
        *stream >> id;
        if (nodes->contains(id)) {
            currentGraph->addEdge(edgeName, *nodes->find(id), metaNode, currentGraph->getEdgeMetaType(), true);
            selectedNodes->append(*nodes->find(id));
        }
    }

    Server * server = Server::getInstance();
    server->sendAddMetaNode(metaNode,selectedNodes,edgeName,osg::Vec3(x,y,z));

    if (((QOSG::CoreWindow *)server->getCoreWindowReference())->playing()) {
        server->getLayoutThread()->play();
    }


}
开发者ID:FilipMikle,项目名称:Arvis,代码行数:36,代码来源:AddMetaNodeExecutor.cpp

示例5: getEdges

void RemoveEdgeExecutor::execute_server()
{

	int id;

	*stream >> id;

	Data::Graph* currentGraph = Manager::GraphManager::getInstance()->getActiveGraph();
	QMap<qlonglong, osg::ref_ptr<Data::Edge> >* edges = currentGraph -> getEdges();
	if ( edges->contains( id ) ) {
		Data::Edge* edge = *edges->find( id );
		if ( edge != NULL ) {
			currentGraph->removeEdge( edge );
		}
	}

	Server* server = Server::getInstance();
	server->sendRemoveEdge( id );

	if ( ( ( QOSG::CoreWindow* )server->getCoreWindowReference() )->playing() ) {
		server->getLayoutThread()->play();
	}

}
开发者ID:vexta,项目名称:3dsoftviz,代码行数:24,代码来源:RemoveEdgeExecutor.cpp

示例6: test_enums

bool test_enums() {
    printf("\n*** test_enums()\n");

    Network yarp;
    yarp.setLocalMode(true);

    Demo client;
    Server server;

    Port client_port,server_port;
    client_port.open("/client");
    server_port.open("/server");
    yarp.connect(client_port.getName(),server_port.getName());
    client.yarp().attachAsClient(client_port);
    server.yarp().attachAsServer(server_port);

    std::vector<DemoEnum> lst1;
    lst1.push_back(ENUM1);
    lst1.push_back(ENUM2);
    std::vector<DemoEnum> lst2 = client.test_enum_vector(lst1);
    printf("lst1 %d lst2 %d\n", lst1.size(), lst2.size());

    return (lst2.size()==3 && lst1[0]==lst2[0] && lst1[1]==lst2[1]);
}
开发者ID:paulfitz,项目名称:yarp,代码行数:24,代码来源:main.cpp

示例7: main

int main(int argc, char ** argv) {

  if(argc != 2) {
    printf("Usage: %s number-of-clients\n", argv[0]);
    exit(1);
  }

  int clientsNumber = atoi(argv[1]);

  require(clientsNumber >= 3 && clientsNumber <= 6,
    "The numbers of clients in a game should be between 3 and 6.\n");

  Table::TABLE_SIZE = clientsNumber;

  Table table;
  Server server;

  while(true) {
    const int n = server.poll();
    //there are n new incoming connections
    for(int i = 0; i < n; ++i) {
      const int client = server.acceptConnection();
      
      if(table.GAME_END) {
          Table newTable;
          table = newTable;
      }

      table.addPlayer(client);
    }

    std::this_thread::sleep_for(std::chrono::milliseconds(100));
  }

  return 0;
}
开发者ID:Thomas1995,项目名称:Rentz,代码行数:36,代码来源:server.cpp

示例8: ServerAllocation

UDPAllocation::UDPAllocation(Server& server,
                             const FiveTuple& tuple, 
                             const std::string& username, 
                             const UInt32& lifetime) : 
	ServerAllocation(server, tuple, username, lifetime)//,
	//_relaySocket(new net::UDPSocket) //server.reactor(), server.runner()
{
	// Handle data from the relay socket directly from the allocation.
	// This will remove the need for allocation lookups when receiving
	// data from peers.
	_relaySocket.bind(net::Address(server.options().listenAddr.host(), 0));		
	_relaySocket.Recv += sdelegate(this, &UDPAllocation::onPeerDataReceived);

	TraceL << " Initializing on address: " << _relaySocket.address() << endl;
}
开发者ID:AsamQi,项目名称:libsourcey,代码行数:15,代码来源:udpallocation.cpp

示例9: main

int main(int argc, char** argv)
{
	
	uid_t uID = getuid();

	if(uID != 0)
	{
		std::cout << "You are not running as root, this will cause problems.\n";
	}

	server.startX();
	while(!server.pollServer()) {
		usleep(5*1000);
	}

	QApplication app(argc, argv);
	double ppi = app.primaryScreen()->physicalDotsPerInch();
	//std::cout << "Your ppi is " << ppi << "\n";
	Window window;
	if(ppi >= 200.00) {
		/* HiDPI
		** some hidpi font setting hack
        ** Qt5 should be getting proper hidpi support on linux soon?
		*/
		window.isHiDPI(true);
		QFont font = app.font();
		font.setPointSize(font.pointSize()*2);
		app.setFont(font);
	}
	window.resize(app.primaryScreen()->size());
	window.setWindowFlags(Qt::FramelessWindowHint);
	window.update();
	window.show();

	return app.exec();
}
开发者ID:lotusronin,项目名称:MarcDM,代码行数:36,代码来源:main.cpp

示例10: Run

	/*
	 * NICK - NEW
	 * Received: :dev.anope.de NICK DukeP_ 1 ~DukePyro ip-2-201-236-154.web.vodafone.de 1 + :DukePyrolator
	 * Parameters: <nickname> <hopcount> <username> <host> <servertoken> <umode> :<realname>
	 * source = server
	 * params[0] = nick
	 * params[1] = hopcount
	 * params[2] = username/ident
	 * params[3] = host
	 * params[4] = servertoken
	 * params[5] = modes
	 * params[6] = info
	 *
	 * NICK - change
	 * Received: :DukeP_ NICK :test2
	 * source    = oldnick
	 * params[0] = newnick
	 *
	 */
	void Run(MessageSource &source, const std::vector<Anope::string> &params) override
	{
		if (params.size() == 1)
		{
			// we have a nickchange
			source.GetUser()->ChangeNick(params[0]);
		}
		else if (params.size() == 7)
		{
			// a new user is connecting to the network
			Server *s = Server::Find(params[4]);
			if (s == NULL)
			{
				Log(LOG_DEBUG) << "User " << params[0] << " introduced from non-existent server " << params[4] << "?";
				return;
			}
			User::OnIntroduce(params[0], params[2], params[3], "", "", s, params[6], Anope::CurTime, params[5], "", NULL);
			Log(LOG_DEBUG) << "Registered nick \"" << params[0] << "\" on server " << s->GetName() << ".";
		}
		else
		{
			Log(LOG_DEBUG) << "Received NICK with invalid number of parameters. source = " << source.GetName() << "params[0] = " << params[0] << "params.size() = " << params.size();
		}
	}
开发者ID:bonnedav,项目名称:anope,代码行数:43,代码来源:ngircd.cpp

示例11: read_v3s16

// rollback_get_node_actions(pos, range, seconds, limit) -> {{actor, pos, time, oldnode, newnode}, ...}
int ModApiRollback::l_rollback_get_node_actions(lua_State *L)
{
	v3s16 pos = read_v3s16(L, 1);
	int range = luaL_checknumber(L, 2);
	time_t seconds = (time_t) luaL_checknumber(L, 3);
	int limit = luaL_checknumber(L, 4);
	Server *server = getServer(L);
	IRollbackManager *rollback = server->getRollbackManager();

	std::list<RollbackAction> actions = rollback->getNodeActors(pos, range, seconds, limit);
	std::list<RollbackAction>::iterator iter = actions.begin();

	lua_createtable(L, actions.size(), 0);
	for (unsigned int i = 1; iter != actions.end(); ++iter, ++i) {
		lua_createtable(L, 0, 5); // Make a table with enough space pre-allocated

		lua_pushstring(L, iter->actor.c_str());
		lua_setfield(L, -2, "actor");

		push_v3s16(L, iter->p);
		lua_setfield(L, -2, "pos");

		lua_pushnumber(L, iter->unix_time);
		lua_setfield(L, -2, "time");

		push_RollbackNode(L, iter->n_old);
		lua_setfield(L, -2, "oldnode");

		push_RollbackNode(L, iter->n_new);
		lua_setfield(L, -2, "newnode");

		lua_rawseti(L, -2, i); // Add action table to main table
	}

	return 1;
}
开发者ID:1CoreyDev1,项目名称:minetest,代码行数:37,代码来源:l_rollback.cpp

示例12: serverHtmlLabel

static QString serverHtmlLabel(const Server &s)
{
    // No server info available
    QString label = s.label();
    if (s.uuid().isEmpty() && s.version().isEmpty())
        label = s.nativeUrl();
    if (s.label().isEmpty())
        label = tkTr(Trans::Constants::_1_COLON_2).arg(tkTr(Trans::Constants::UNKNOWN_SERVER)).arg(s.nativeUrl());
    label = QString("<span style=\"color:black;font-weight:bold;\">%1</span>")
            .arg(label);

    if (s.isConnected()) {
        if (s.lastChecked().isValid())
            label += QString("<br /><span style=\"color:gray; font-size:small;\">%2 (%3: %4)</span>")
                    .arg(tkTr(Trans::Constants::CONNECTED))
                    .arg(tkTr(Trans::Constants::LAST_CHECK))
                    .arg(s.lastChecked().toString(QLocale().dateFormat(QLocale::LongFormat)));
        else
            label += QString("<br /><span style=\"color:gray; font-size:small;\">%2</span>")
                    .arg(tkTr(Trans::Constants::CONNECTED));
    } else {
        label += QString("<br /><span style=\"color:gray; font-size:small;\">%2</span>")
                .arg(tkTr(Trans::Constants::NOT_CONNECTED));
    }

    label += QString("<br /><span style=\"color:gray; font-size:small;\">%1 %2</span>")
            .arg(serverManager()->getPackForServer(s).count())
            .arg(tkTr(Trans::Constants::PACKAGES));

    if (!s.errors().isEmpty()) {
        label += QString("<br /><span style=\"color:marron; font-size:small;\">%1: %2</span>")
                .arg(tkTr(Trans::Constants::ERRORS))
                .arg(s.errors().count());
    }
    return label;
}
开发者ID:eads77m,项目名称:freemedforms,代码行数:36,代码来源:servermodel.cpp

示例13: TEST

TEST (TestServer, DefineStream) {
    Server server;

    try {
        std::stringstream is1("CREATE STREAM TESTSTREAM1(ID INT, NAME STRING)");
        InputStreamHandler::ptr_t test_stream1 = define_stream_from_ddl(server, is1);
        EXPECT_TRUE(server.has_stream_with_name("TESTSTREAM1"));

        std::stringstream is2("CREATE STREAM TESTSTREAM2(ID INT, NAME STRING, AGE INT)");
        InputStreamHandler::ptr_t test_stream2 = define_stream_from_ddl(server, is2);
        EXPECT_TRUE(server.has_stream_with_name("TESTSTREAM2"));

        server.get_stream_adapter_by_name("TESTSTREAM1");
        server.get_stream_adapter_by_name("TESTSTREAM2");

        // server.register_query(
        //     "QUERY1",
        //     "TESTSTREAM1",
        //     Operator::ptr_t(
        //         new OperatorStreamAdapter(server.get_stream("TESTSTREAM1"))
        //     )
        // );

        // server.register_query_legacy(
        //     "QUERY1",
        //     Operator::ptr_t(
        //         server.get_stream_adapter_by_name("TESTSTREAM1")
        //     )
        // );
    } catch (std::string error) {
        std::cout << error << std::endl;
        EXPECT_TRUE(false);
    }

    // EXPECT_EQ();
}
开发者ID:mooz,项目名称:currentia,代码行数:36,代码来源:test_server.cpp

示例14: run

  // From ServerApplication
  void run() {
    // Require a valid certificate from client
    sslCtx.setVerifyPeer(true, true);

    // Load certificates and keys
    sslCtx.useCertificateChainFile("server.pem");
    sslCtx.usePrivateKey(InputSource("server.pem"));
    //sslCtx.addTrustedCA("root.pem");
    //sslCtx.addCRL("crl.pem");

    // Test BIMemory
    uint64_t length = SystemUtilities::getFileSize("root.pem");
    SmartPointer<iostream> f = SystemUtilities::open("root.pem", ios::in);
    SmartPointer<char> buf = new char[length];
    f->read(buf.get(), length);
    if (f->fail()) THROWS("Failed reading root.pem");

    BIMemory bio(buf.get(), length);
    sslCtx.addTrustedCA(bio.getBIO());

    server.start();
    while (!quit) Timer::sleep(0.1);
    server.join();
  }
开发者ID:equinoxefr,项目名称:cbang,代码行数:25,代码来源:secure_webserver.cpp

示例15: HasServer

Player::Player(const std::string& name, boost::uuids::uuid uuid,
               std::shared_ptr<Session> session, std::int32_t id,
               Server& server, World* world, Gamemode gamemode)
    : HasServer(server), CommandSender(commands::CommandSenderType::Player), mUUID(uuid), mNickname(name),
      mWorld(world),
      session(session), gamemode(gamemode),
      mSendKeepAliveTimer(server.getWorkIO()), mTeleportID(0),
      mEntityID(id), hasSavedToDisk(false) {
  Logger::debug((boost::format("Player %1% created") % this).str());

  loadFromFile();

  mLastPositionWhenChunksWasSent.x = 0;
  mLastPositionWhenChunksWasSent.z = 0;
}
开发者ID:xTachyon,项目名称:RedstoneInside,代码行数:15,代码来源:player.cpp


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