示例#1
0
	int main(const std::vector<std::string>&)
	{
    unsigned short port = (unsigned short) config().getInt("HttpRouter.port", 9443);

    std::cout << port << std::endl;

    Poco::Net::SecureServerSocket svs(port);

    HttpRouter* router = new HttpRouter();

    router->AddRoute("/foo", GetHandler, "GET");
    router->AddRoute("/foo/bar", OtherGetHandler, "GET");
    router->AddRoute("/foo", PostHandler, "POST");
    router->AddRoute("/bar", HandlerClass(), "GET");
    router->AddRoute("/", DefaultRequestHandler);

    auto params = new Poco::Net::HTTPServerParams();

    Poco::Net::HTTPServer srv(router, svs, params);
    srv.start();
    waitForTerminationRequest();
    srv.stop();

    return Poco::Util::Application::EXIT_OK;
  }
示例#2
0
  int main(const std::vector<std::string>& args)
  {
    ScopedLogMessage msg(" main() ", "start", "end");
 
    if(m_helpRequested)
      {
	displayHelp();
      }
    else
      {
	CommandDispatcher	commandDispatcher(msg);
 
	unsigned short port = (unsigned short) config().getInt("MyTCPServer.port", 9923);
	Poco::Net::ServerSocket svs(port);
	Poco::Net::TCPServer srv(new TCPConnectionFactory(msg, commandDispatcher),
				 svs, new Poco::Net::TCPServerParams);
	srv.start();
 
	// wait for CTRL-C or kill
	waitForTerminationRequest();
 
	srv.stop();
      }
    return Poco::Util::Application::EXIT_OK;
  }
示例#3
0
wdmSystem::wdmSystem()
    : m_end_flag(false)
    , m_root(NULL)
    , m_server(NULL)
{
    s_inst = this;
    m_conf.load((std::string(GetCurrentModuleDirectory())+"wdmConfig.txt").c_str());
    m_root = new wdmNodeBase();

#ifndef wdmDisableEnumMemberVariables
    ::SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_DEBUG);
    ::SymInitialize(::GetCurrentProcess(), NULL, TRUE);
#endif // wdmDisableEnumMemberVariables


	if (!m_server && !m_conf.disabled) {
        Poco::Net::HTTPServerParams* params = new Poco::Net::HTTPServerParams;
        params->setMaxQueued(m_conf.max_queue);
        params->setMaxThreads(m_conf.max_threads);
        params->setThreadIdleTime(Poco::Timespan(3, 0));

        try {
            Poco::Net::ServerSocket svs(m_conf.port);
            m_server = new Poco::Net::HTTPServer(new wdmRequestHandlerFactory(), svs, params);
            m_server->start();
        }
        catch(Poco::IOException &) {
        }
    }
}
	int main(const std::vector<std::string>& args)
	{
		if (_helpRequested)
		{
			displayHelp();
		}
		else
		{
			// get parameters from configuration file
			unsigned short port = (unsigned short)config().getInt("TimeServer.port", 9911);
			std::string format(config().getString("TimeServer.format", Poco::DateTimeFormat::ISO8601_FORMAT));

			// set-up a server socket
			Poco::Net::ServerSocket svs(port);
			// set-up a TCPServer instance
			Poco::Net::TCPServer srv(new TimeServerConnectionFactory(format), svs);
			// start the TCPServer
			srv.start();

			// start push thread
			Poco::Thread thread;
			PushRunnable runnable;
			thread.start(runnable);

			// wait for CTRL-C or kill
			waitForTerminationRequest();
			// Stop the TCPServer
			srv.stop();
		}
		return Application::EXIT_OK;
	}
示例#5
0
void SoapServerInternal::Start()
{
	if (m_running)
	{
		assert(false);
		return;
	}

	Poco::Net::ServerSocket mex(m_mexPort);
	Poco::Net::ServerSocket svs(m_rpcPort);

	//Configure some server params.
	Poco::Net::TCPServerParams* pTcpParams = new Poco::Net::TCPServerParams();
	pTcpParams->setMaxThreads(16);
	pTcpParams->setMaxQueued(1);

	Poco::Net::HTTPServerParams* pHttpParams = new Poco::Net::HTTPServerParams;
	pHttpParams->setMaxThreads(4);

	//Create your server
	
	m_soapTcpServer = shared_ptr<Poco::Net::TCPServer>(new Poco::Net::TCPServer(new TCPServerConnectionFactorySoap(this), svs, pTcpParams));
	m_mexHttpServer = shared_ptr<Poco::Net::HTTPServer>(new Poco::Net::HTTPServer(new MexHTTPRequestHandlerFactory(m_wsdlPath), mex, pHttpParams));

	m_soapTcpServer->start();
	m_mexHttpServer->start();

	m_running = true;
}
void ZenAudioProcessorValueTreeState::updateParameterConnectionsToChildTrees()
{
	if (!updatingConnections)
	{
		ScopedValueSetter<bool> svs(updatingConnections, true, false);

		const int numParams = processor.getParameters().size();

		for (int i = 0; i < numParams; ++i)
		{
			AudioProcessorParameter* const ap = processor.getParameters().getUnchecked(i);
			jassert(dynamic_cast<ZenParameter*> (ap) != nullptr);

			ZenParameter* p = static_cast<ZenParameter*> (ap);
			p->setNewState(getOrCreateChildValueTree(p->paramID));
		}
	}
}
示例#7
0
int ChatServer::main(const std::vector<std::string>& args)
{
    unsigned short port = 10000;
    Poco::Net::ServerSocket svs(port);
    Poco::Net::SocketReactor reactor;
    
    Poco::Net::ParallelSocketAcceptor<ChatServerHandler, Poco::Net::SocketReactor> acceptors(svs, reactor, 4);
    
    Poco::Thread reactorThread, commandThread;
    reactorThread.start(reactor);
    
//    Poco::NotificationQueue queue;
//    CommandExecutor commandExecutor(queue);


    commandThread.start(commandExecutor);
    waitForTerminationRequest();
    queue.wakeUpAll();
    reactor.stop();
    reactorThread.join();
    commandThread.join();
    
    return Application::EXIT_OK;
}
示例#8
0
int AuthServer::main(const std::vector<std::string>& args)
{
    Poco::Logger::root().information("TRILOGY-CORE");
    Poco::Logger::root().information("AUTHSERVER");
    std::cout << vers_major << "." << vers_minor << "." << patch << std::endl;
    //on charge la configuration du serveur
    if (!sConfigMgr->loadInitial(config))
    {
        return EXIT_CONFIG;
    }

    _params = new Poco::Net::TCPServerParams;
    _params->setMaxThreads(sConfigMgr->GetIntDefault("authserver.maxThreadNumber", 4));
    _params->setMaxQueued(sConfigMgr->GetIntDefault("authserver.maxConnectionQueued", 100));
    _params->setThreadIdleTime(100);

    //Create a server socket, does bind + listen
    Poco::Net::ServerSocket svs(sConfigMgr->GetIntDefault("authServerPort",5555));
    //on crée le serveur de connexion
    _server = new Poco::Net::TCPServer(new AuthSessionFactory(), svs, _params);
    //on lance le serveur de connexion
    _server->start();
    Poco::Logger::root().information("Serveur de connexion lancé sur le port :");
    Poco::Logger::root().information(Poco::NumberFormatter::format(_server->port()));
    waitForTerminationRequest();  // wait for CTRL-C or kill
    Poco::Logger::root().information("Fermeture du serveur...");
    Poco::Logger::root().information(Poco::NumberFormatter::format(_server->totalConnections()));
    //on arrete le serveur de connexion
    _server->stop();
    //on regarde si il reste des connexions active
    if (_server->currentConnections() != 0)
    {
        svs.close();
    }
    return EXIT_OK;
}