示例#1
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 &) {
        }
    }
}
示例#2
0
    virtual Poco::Net::HTTPRequestHandler* createRequestHandler(const Poco::Net::HTTPServerRequest &request)
    {
        if(wdmSystem::getInstance()->getEndFlag()) { return NULL; }

        if(request.getURI() == "/") {
            return new wdmFileRequestHandler(std::string(GetCurrentModuleDirectory())+std::string(s_root_dir)+"/index.html");
        }
        else if(request.getURI()=="/command" || request.getURI()=="/data") {
            return new wdmCommandHandler();
        }
        else {
            std::string path = std::string(GetCurrentModuleDirectory())+std::string(s_root_dir)+request.getURI();
            Poco::File file(path);
            if(file.exists()) {
                return new wdmFileRequestHandler(path);
            }
            else {
                return NULL;
            }
        }
    }
bool SDKFunction::LoadSdkDll()
{
	std::wstring dir = GetCurrentModuleDirectory();
#ifdef _DEBUG
	dir.append(kSdkNimDll_d);
#else
	dir.append(kSdkNimDll);
#endif
	instance_nim_ = ::LoadLibraryW(dir.c_str());
	if (instance_nim_ == NULL)
	{
		//QLOG_ERR(L"sdk nim load fail {0} {1}") << dir << GetLastError();
		return false;
	}

	return true;
}