mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-14 02:57:45 +01:00
updated tour
This commit is contained in:
parent
f828ae1e1f
commit
e522f90513
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 30 KiB |
@ -69,7 +69,7 @@ and a pointer to a member function. The event can be fired by calling
|
||||
#include <iostream>
|
||||
|
||||
using Poco::BasicEvent;
|
||||
using Poco::Delegate;
|
||||
using Poco::delegate;
|
||||
|
||||
class Source
|
||||
{
|
||||
@ -96,13 +96,11 @@ and a pointer to a member function. The event can be fired by calling
|
||||
Source source;
|
||||
Target target;
|
||||
|
||||
source.theEvent += Delegate<Target, int>(
|
||||
&target, &Target::onEvent);
|
||||
source.theEvent += delegate(&target, &Target::onEvent);
|
||||
|
||||
source.fireEvent(42);
|
||||
|
||||
source.theEvent -= Delegate<Target, int>(
|
||||
&target, &Target::onEvent);
|
||||
source.theEvent -= delegate(&target, &Target::onEvent);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -315,12 +313,11 @@ server.
|
||||
{
|
||||
}
|
||||
|
||||
void handleRequest(HTTPServerRequest& request,
|
||||
HTTPServerResponse& response)
|
||||
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
|
||||
{
|
||||
Application& app = Application::instance();
|
||||
app.logger().information("Request from "
|
||||
+ request.clientAddress().toString());
|
||||
app.logger().information("Request from %s",
|
||||
request.clientAddress().toString());
|
||||
|
||||
Timestamp now;
|
||||
std::string dt(DateTimeFormatter::format(now, _format));
|
||||
@ -350,8 +347,7 @@ server.
|
||||
{
|
||||
}
|
||||
|
||||
HTTPRequestHandler* createRequestHandler(
|
||||
const HTTPServerRequest& request)
|
||||
HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request)
|
||||
{
|
||||
if (request.getURI() == "/")
|
||||
return new TimeRequestHandler(_format);
|
||||
@ -365,15 +361,6 @@ server.
|
||||
|
||||
class HTTPTimeServer: public Poco::Util::ServerApplication
|
||||
{
|
||||
public:
|
||||
HTTPTimeServer(): _helpRequested(false)
|
||||
{
|
||||
}
|
||||
|
||||
~HTTPTimeServer()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void initialize(Application& self)
|
||||
{
|
||||
@ -381,11 +368,6 @@ server.
|
||||
ServerApplication::initialize(self);
|
||||
}
|
||||
|
||||
void uninitialize()
|
||||
{
|
||||
ServerApplication::uninitialize();
|
||||
}
|
||||
|
||||
void defineOptions(OptionSet& options)
|
||||
{
|
||||
ServerApplication::defineOptions(options);
|
||||
@ -398,8 +380,7 @@ server.
|
||||
this, &HTTPTimeServer::handleHelp)));
|
||||
}
|
||||
|
||||
void handleHelp(const std::string& name,
|
||||
const std::string& value)
|
||||
void handleHelp(const std::string& name, const std::string& value)
|
||||
{
|
||||
HelpFormatter helpFormatter(options());
|
||||
helpFormatter.setCommand(commandName());
|
||||
@ -415,14 +396,15 @@ server.
|
||||
{
|
||||
if (!_helpRequested)
|
||||
{
|
||||
unsigned short port = (unsigned short)
|
||||
config().getInt("HTTPTimeServer.port", 9980);
|
||||
std::string format(
|
||||
config().getString("HTTPTimeServer.format",
|
||||
unsigned short port = static_cast<unsigned short>(
|
||||
config().getInt("HTTPTimeServer.port", 9980));
|
||||
std::string format(config().getString(
|
||||
"HTTPTimeServer.format",
|
||||
DateTimeFormat::SORTABLE_FORMAT));
|
||||
|
||||
ServerSocket svs(port);
|
||||
HTTPServer srv(new TimeRequestHandlerFactory(format),
|
||||
HTTPServer srv(
|
||||
new TimeRequestHandlerFactory(format),
|
||||
svs, new HTTPServerParams);
|
||||
srv.start();
|
||||
waitForTerminationRequest();
|
||||
@ -432,7 +414,7 @@ server.
|
||||
}
|
||||
|
||||
private:
|
||||
bool _helpRequested;
|
||||
bool _helpRequested = false;
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
Loading…
Reference in New Issue
Block a user