Tweak send/receive visibility

This commit is contained in:
Fred Nicolson 2019-05-17 11:38:59 +01:00
parent 12f1d7b0ce
commit 81118e6606
No known key found for this signature in database
GPG Key ID: 78C1DD87B47797D2
3 changed files with 27 additions and 26 deletions

View File

@ -315,6 +315,29 @@ namespace fr
return type;
}
/*!
* Overridable send, to allow
* custom types to be directly sent through
* sockets.
*
* @param socket The socket to send through
* @return Status indicating if the send succeeded or not.
*/
Socket::Status send(Socket *socket) const override;
/*!
* Overrideable receive, to allow
* custom types to be directly received through
* sockets.
*
* @param socket The socket to send through
* @return Status indicating if the send succeeded or not:
* 'Success': All good, object still valid.
* 'WouldBlock' or 'Timeout': No data received. Object still valid though.
* Anything else: Object invalid. Call disconnect().
*/
Socket::Status receive(Socket *socket) override;
protected:
/*!
* Splits a string by new line. Ignores escaped \n's
@ -340,28 +363,7 @@ namespace fr
*/
void parse_header_line(const std::string &str);
/*!
* Overridable send, to allow
* custom types to be directly sent through
* sockets.
*
* @param socket The socket to send through
* @return Status indicating if the send succeeded or not.
*/
Socket::Status send(Socket *socket) const override;
/*!
* Overrideable receive, to allow
* custom types to be directly received through
* sockets.
*
* @param socket The socket to send through
* @return Status indicating if the send succeeded or not:
* 'Success': All good, object still valid.
* 'WouldBlock' or 'Timeout': No data received. Object still valid though.
* Anything else: Object invalid. Call disconnect().
*/
Socket::Status receive(Socket *socket) override;
//Other request info
std::unordered_map<std::string, std::string> header_data;

View File

@ -690,9 +690,6 @@ namespace fr
return buffer.size() <= PACKET_HEADER_LENGTH ? 0 : buffer.size() - PACKET_HEADER_LENGTH;
}
private:
friend class Socket;
/*!
* Overridable send, to allow
* custom types to be directly sent through
@ -748,10 +745,13 @@ namespace fr
status = socket->receive_all(&buffer[PACKET_HEADER_LENGTH], packet_length);
} while(status == fr::Socket::Status::WouldBlock);
if(status == fr::Socket::Status::Timeout)
status = fr::Socket::Status::Disconnected;
status = fr::Socket::Status::Disconnected;
return status;
}
private:
friend class Socket;
mutable std::string buffer; //Packet data buffer
size_t buffer_read_index; //Current read position

View File

@ -94,7 +94,6 @@ namespace fr
final = is_final;
}
protected:
/*!
* Overridable send, to allow
* custom types to be directly sent through