fix for change for SF# 2807639

This commit is contained in:
Marian Krivos 2009-06-22 11:16:52 +00:00
parent 122fc1216e
commit c8e2c4f010

View File

@ -14,14 +14,14 @@
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
@ -54,7 +54,7 @@ using Poco::Net::ShutdownNotification;
using Poco::Net::ServerSocket;
using Poco::Net::StreamSocket;
using Poco::NObserver;
using Poco::Notification;
using Poco::AutoPtr;
using Poco::Thread;
using Poco::Util::ServerApplication;
using Poco::Util::Application;
@ -77,7 +77,7 @@ public:
_reactor.addEventHandler(_socket, NObserver<EchoServiceHandler, ReadableNotification>(*this, &EchoServiceHandler::onReadable));
_reactor.addEventHandler(_socket, NObserver<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown));
}
~EchoServiceHandler()
{
Application& app = Application::instance();
@ -92,8 +92,8 @@ public:
_reactor.removeEventHandler(_socket, NObserver<EchoServiceHandler, ShutdownNotification>(*this, &EchoServiceHandler::onShutdown));
delete [] _pBuffer;
}
void onReadable(const Notification::Ptr& pNf)
void onReadable(const AutoPtr<ReadableNotification>& pNf)
{
int n = _socket.receiveBytes(_pBuffer, BUFFER_SIZE);
if (n > 0)
@ -101,18 +101,18 @@ public:
else
delete this;
}
void onShutdown(const Notification::Ptr& pNf)
void onShutdown(const AutoPtr<ShutdownNotification>& pNf)
{
delete this;
}
private:
enum
{
BUFFER_SIZE = 1024
};
StreamSocket _socket;
SocketReactor& _reactor;
char* _pBuffer;
@ -142,7 +142,7 @@ public:
EchoServer(): _helpRequested(false)
{
}
~EchoServer()
{
}
@ -153,7 +153,7 @@ protected:
loadConfiguration(); // load default configuration files, if present
ServerApplication::initialize(self);
}
void uninitialize()
{
ServerApplication::uninitialize();
@ -162,7 +162,7 @@ protected:
void defineOptions(OptionSet& options)
{
ServerApplication::defineOptions(options);
options.addOption(
Option("help", "h", "display help information on command line arguments")
.required(false)
@ -196,14 +196,14 @@ protected:
{
// get parameters from configuration file
unsigned short port = (unsigned short) config().getInt("EchoServer.port", 9977);
// set-up a server socket
ServerSocket svs(port);
// set-up a SocketReactor...
SocketReactor reactor;
// ... and a SocketAcceptor
SocketAcceptor<EchoServiceHandler> acceptor(svs, reactor);
// run the reactor in its own thread so that we can wait for
// run the reactor in its own thread so that we can wait for
// a termination request
Thread thread;
thread.start(reactor);
@ -215,7 +215,7 @@ protected:
}
return Application::EXIT_OK;
}
private:
bool _helpRequested;
};
@ -226,3 +226,4 @@ int main(int argc, char** argv)
EchoServer app;
return app.run(argc, argv);
}