ScummVM API documentation
Networking::Client Class Reference

#include <client.h>

Public Member Functions

 Client (SDLNet_SocketSet set, TCPsocket socket)
 
void open (SDLNet_SocketSet set, TCPsocket socket)
 
void readHeaders ()
 
bool readContent (Common::WriteStream *stream)
 
bool readFirstContent (Common::WriteStream *stream)
 
bool readBlockHeaders (Common::WriteStream *stream)
 
bool readBlockContent (Common::WriteStream *stream)
 
void setHandler (ClientHandler *handler)
 
void handle ()
 
void close ()
 
ClientState state () const
 
Common::String headers () const
 
Common::String method () const
 
Common::String path () const
 
Common::String query () const
 
Common::String queryParameter (const Common::String &name) const
 
Common::String anchor () const
 
bool noMoreContent () const
 
bool socketIsReady ()
 
int recv (void *data, int maxlen)
 
int send (void *data, int len)
 

Detailed Description

Client class represents one client's HTTP request to the LocalWebserver.

While in READING_HEADERS state, it's kept in LocalWebserver. Client must read the headers and decide whether it's READ_HEADERS (could be handled) or BAD_REQUEST (failed).

If it's READ_HEADERS, LocalWebserver searches for a corresponding BaseHandler. These classes use the information from headers - like method, path, GET parameters - to build the response for this client's request. When they do, they call setHandler() and pass a special ClientHandler. Client becomes BEING_HANDLED.

While in that state, LocalWebserver calls Client's handle() and it's passed to ClientHandler. The latter does the job: it commands Client to read or write bytes with its socket or calls readContent() methods, so Client reads the request through Reader.

Member Function Documentation

◆ socketIsReady()

bool Networking::Client::socketIsReady ( )

Return SDLNet_SocketReady(_socket).

It's "ready" when it has something to read (recv()). You can send() when this is false.


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