00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "HelloService.hpp"
00011 #include <pion/net/HTTPResponseWriter.hpp>
00012
00013 using namespace pion;
00014 using namespace pion::net;
00015
00016 namespace pion {
00017 namespace plugins {
00018
00019
00020
00021
00023 void HelloService::operator()(HTTPRequestPtr& request, TCPConnectionPtr& tcp_conn)
00024 {
00025 static const std::string HELLO_HTML = "<html><body>Hello World!</body></html>";
00026 HTTPResponseWriterPtr writer(HTTPResponseWriter::create(tcp_conn, *request,
00027 boost::bind(&TCPConnection::finish, tcp_conn)));
00028 writer->writeNoCopy(HELLO_HTML);
00029 writer->writeNoCopy(HTTPTypes::STRING_CRLF);
00030 writer->writeNoCopy(HTTPTypes::STRING_CRLF);
00031 writer->send();
00032 }
00033
00034
00035 }
00036 }
00037
00038
00040 extern "C" PION_SERVICE_API pion::plugins::HelloService *pion_create_HelloService(void)
00041 {
00042 return new pion::plugins::HelloService();
00043 }
00044
00046 extern "C" PION_SERVICE_API void pion_destroy_HelloService(pion::plugins::HelloService *service_ptr)
00047 {
00048 delete service_ptr;
00049 }