diff options
author | Alexander Tkachev | 2016-06-15 23:54:53 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 13c54f66850226a516da0450b633ebafbc26584e (patch) | |
tree | 5c2582cc47296bee1fd3dc7e8f55bddb102bc61f /backends/networking/sdl_net/client.h | |
parent | 99c51380fdc866ce393c52eb41803a9ec119a9ad (diff) | |
download | scummvm-rg350-13c54f66850226a516da0450b633ebafbc26584e.tar.gz scummvm-rg350-13c54f66850226a516da0450b633ebafbc26584e.tar.bz2 scummvm-rg350-13c54f66850226a516da0450b633ebafbc26584e.zip |
CLOUD: Add GetClientHandler
That ClientHandler is made for responding GET requests. It calculates
stream's length, it allows to specify response code and headers, it can
be used to transfer any ReadStream.
Diffstat (limited to 'backends/networking/sdl_net/client.h')
-rw-r--r-- | backends/networking/sdl_net/client.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/backends/networking/sdl_net/client.h b/backends/networking/sdl_net/client.h index 7f78947223..8b7a7d5295 100644 --- a/backends/networking/sdl_net/client.h +++ b/backends/networking/sdl_net/client.h @@ -35,7 +35,16 @@ enum ClientState { INVALID, READING_HEADERS, READ_HEADERS, - BAD_REQUEST + BAD_REQUEST, + BEING_HANDLED +}; + +class Client; + +class ClientHandler { +public: + virtual ~ClientHandler() {}; + virtual void handle(Client *client) = 0; }; class Client { @@ -43,6 +52,7 @@ class Client { SDLNet_SocketSet _set; TCPsocket _socket; Common::String _headers; + ClientHandler *_handler; void checkIfHeadersEnded(); void checkIfBadRequest(); @@ -54,10 +64,23 @@ public: void open(SDLNet_SocketSet set, TCPsocket socket); void readHeaders(); + void setHandler(ClientHandler *handler); + void handle(); void close(); ClientState state(); Common::String headers(); + + /** + * Return SDLNet_SocketReady(_socket). + * + * It's "ready" when it has something + * to read (recv()). You can send() + * when this is false. + */ + bool socketIsReady(); + int recv(void *data, int maxlen); + int send(void *data, int len); }; } // End of namespace Networking |