mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 19:51:58 +01:00
added support to get client id
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "Poco/WebWidgets/WebApplication.h"
|
||||
#include "Poco/WebWidgets/RequestProcessor.h"
|
||||
#include "Poco/Net/HTMLForm.h"
|
||||
#include "Poco/Net/HTTPServerRequest.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -44,6 +45,7 @@ namespace WebWidgets {
|
||||
|
||||
|
||||
Poco::ThreadLocal<WebApplication*> WebApplication::_pInstance;
|
||||
Poco::ThreadLocal<std::string> WebApplication::_clientMachine;
|
||||
|
||||
|
||||
WebApplication::WebApplication(const Poco::URI& uri,ResourceManager::Ptr pRM):
|
||||
@@ -53,7 +55,8 @@ WebApplication::WebApplication(const Poco::URI& uri,ResourceManager::Ptr pRM):
|
||||
_uri(uri)
|
||||
{
|
||||
poco_check_ptr (pRM);
|
||||
attachToThread();
|
||||
*_pInstance = this;
|
||||
*_clientMachine = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -76,9 +79,10 @@ void WebApplication::setCurrentPage(Page::Ptr pPage)
|
||||
}
|
||||
|
||||
|
||||
void WebApplication::attachToThread()
|
||||
void WebApplication::attachToThread(Poco::Net::HTTPServerRequest& request)
|
||||
{
|
||||
*_pInstance = this;
|
||||
*_clientMachine = request.getHost();
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +94,12 @@ WebApplication& WebApplication::instance()
|
||||
}
|
||||
|
||||
|
||||
std::string WebApplication::clientHostName()
|
||||
{
|
||||
return *_clientMachine;
|
||||
}
|
||||
|
||||
|
||||
void WebApplication::registerFormProcessor(const std::string& fieldName, RequestProcessor* pProc)
|
||||
{
|
||||
std::pair<RequestProcessorMap::iterator, bool> res = _requestProcessorMap.insert(std::make_pair(fieldName, pProc));
|
||||
|
||||
Reference in New Issue
Block a user