added support to get client id

This commit is contained in:
Peter Schojer
2008-07-09 10:45:45 +00:00
parent e7ce0a5b52
commit 4e7a55a24b
3 changed files with 21 additions and 4 deletions

View File

@@ -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));