INET Framework for OMNeT++/OMNEST
inet::httptools::HttpServerDirect Class Reference

Server module for direct message passing. More...

#include <HttpServerDirect.h>

Inheritance diagram for inet::httptools::HttpServerDirect:
inet::httptools::HttpServerBase inet::httptools::HttpNodeBase inet::ILifecycle inet::httptools::HttpServerDirectEvilA inet::httptools::HttpServerDirectEvilB

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void finish () override
 
virtual void handleMessage (cMessage *msg) override
 
- Protected Member Functions inherited from inet::httptools::HttpServerBase
virtual void refreshDisplay () const override
 
HttpReplyMessagegenerateDocument (HttpRequestMessage *request, const char *resource, int size=0)
 
HttpReplyMessagegenerateResourceMessage (HttpRequestMessage *request, std::string resource, HttpContentType category)
 
HttpReplyMessagehandleGetRequest (HttpRequestMessage *request, std::string resource)
 
HttpReplyMessagegenerateErrorReply (HttpRequestMessage *request, int code)
 
virtual std::string generateBody ()
 
cPacket * handleReceivedMessage (cMessage *msg)
 
void registerWithController ()
 
void readSiteDefinition (std::string file)
 
std::string readHtmlBodyFile (std::string file, std::string path)
 
- Protected Member Functions inherited from inet::httptools::HttpNodeBase
void sendDirectToModule (HttpNodeBase *receiver, cPacket *packet, simtime_t constdelay=0.0, rdObject *rd=nullptr)
 
double transmissionDelay (cPacket *packet)
 
void logRequest (const HttpRequestMessage *httpRequest)
 
void logResponse (const HttpReplyMessage *httpResponse)
 
void logEntry (std::string line)
 
std::string formatHttpRequestShort (const HttpRequestMessage *httpRequest)
 
std::string formatHttpResponseShort (const HttpReplyMessage *httpResponse)
 
std::string formatHttpRequestLong (const HttpRequestMessage *httpRequest)
 
std::string formatHttpResponseLong (const HttpReplyMessage *httpResponse)
 
virtual bool handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 

Additional Inherited Members

- Public Member Functions inherited from inet::httptools::HttpServerBase
 HttpServerBase ()
 
 ~HttpServerBase ()
 
const std::string & getHostName ()
 
- Public Member Functions inherited from inet::httptools::HttpNodeBase
 HttpNodeBase ()
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 
- Protected Attributes inherited from inet::httptools::HttpServerBase
std::string hostName
 
int port = -1
 
bool scriptedMode = false
 
std::map< std::string, HtmlPageDatahtmlPages
 
std::map< std::string, unsigned int > resources
 
simtime_t activationTime
 
long htmlDocsServed = 0
 
long imgResourcesServed = 0
 
long textResourcesServed = 0
 
long badRequests = 0
 
rdObjectrdReplyDelay = nullptr
 The processing delay of the server. More...
 
rdObjectrdHtmlPageSize = nullptr
 The HTML page size distribution for the site. More...
 
rdObjectrdTextResourceSize = nullptr
 The text resource size distribution for the site. More...
 
rdObjectrdImageResourceSize = nullptr
 The image resource size distribution for the site. More...
 
rdObjectrdNumResources = nullptr
 Number of resources per HTML page. More...
 
rdObjectrdTextImageResourceRatio = nullptr
 The ratio of text resources to images referenced in HTML pages. More...
 
rdObjectrdErrorMsgSize = nullptr
 The size of error messages. More...
 
- Protected Attributes inherited from inet::httptools::HttpNodeBase
unsigned long linkSpeed = 0
 
int httpProtocol = 0
 
std::string logFileName
 
bool enableLogging = true
 
LOG_FORMAT outputFormat = lf_short
 
bool m_bDisplayMessage = true
 
bool m_bDisplayResponseContent = true
 
cModule * host = nullptr
 

Detailed Description

Server module for direct message passing.

This module implements a flexible Web server for direct message passing. It is part of the HttpTools project and should be used in conjunction with a number of clients running the HttpBrowserDirect. The module plugs into the DirectHost module.

See also
HttpServerBase
HttpServer
Author
Kristjan V. Jonsson

Member Function Documentation

void inet::httptools::HttpServerDirect::finish ( )
overrideprotectedvirtual

Reimplemented from inet::httptools::HttpServerBase.

40 {
42 }
virtual void finish() override
Definition: HttpServerBase.cc:164
void inet::httptools::HttpServerDirect::handleMessage ( cMessage *  msg)
overrideprotectedvirtual

Implements inet::httptools::HttpServerBase.

45 {
46  EV_DEBUG << "Handling received message " << msg->getName() << endl;
47  if (msg->isSelfMessage()) {
48  // Self messages are not used at the present
49  }
50  else {
51  HttpNodeBase *senderModule = dynamic_cast<HttpNodeBase *>(msg->getSenderModule());
52  if (senderModule == nullptr) {
53  EV_ERROR << "Unspecified sender module in received message " << msg->getName() << endl;
54  delete msg;
55  return;
56  }
57  cModule *senderHost = getContainingNode(senderModule);
58  EV_DEBUG << "Sender is " << senderModule->getFullName()
59  << " in host " << senderHost->getFullName() << endl;
60  cPacket *reply = handleReceivedMessage(msg);
61  // Echo back to the requester
62  if (reply != nullptr)
63  sendDirectToModule(senderModule, reply, 0.0, rdReplyDelay);
64  delete msg;
65  }
66 }
HttpNodeBase()
Definition: HttpNodeBase.cc:26
rdObject * rdReplyDelay
The processing delay of the server.
Definition: HttpServerBase.h:76
void sendDirectToModule(HttpNodeBase *receiver, cPacket *packet, simtime_t constdelay=0.0, rdObject *rd=nullptr)
Definition: HttpNodeBase.cc:43
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
cPacket * handleReceivedMessage(cMessage *msg)
Definition: HttpServerBase.cc:200
void inet::httptools::HttpServerDirect::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::httptools::HttpServerBase.

Reimplemented in inet::httptools::HttpServerDirectEvilA, and inet::httptools::HttpServerDirectEvilB.

Referenced by inet::httptools::HttpServerDirectEvilA::initialize(), and inet::httptools::HttpServerDirectEvilB::initialize().

29 {
31  if (stage == INITSTAGE_LOCAL) {
32  EV_DEBUG << "Initializing direct server component\n";
33 
34  // Set the link speed
35  linkSpeed = par("linkSpeed");
36  }
37 }
unsigned long linkSpeed
Definition: HttpNodeBase.h:59
virtual void initialize(int stage) override
Definition: HttpServerBase.cc:42
Local initializations.
Definition: InitStages.h:35
virtual int inet::httptools::HttpServerDirect::numInitStages ( ) const
inlineoverrideprotectedvirtual

Reimplemented from inet::httptools::HttpServerBase.

Reimplemented in inet::httptools::HttpServerDirectEvilA, and inet::httptools::HttpServerDirectEvilB.

42 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116

The documentation for this class was generated from the following files: