Move GetNextLine from StreamSocket to TreeSocket.

This commit is contained in:
Sadie Powell 2020-07-20 07:50:18 +01:00
parent 90fb7c511f
commit 306594f591
4 changed files with 17 additions and 16 deletions

View File

@ -338,12 +338,6 @@ class CoreExport StreamSocket : public EventHandler
/** Send the given data out the socket, either now or when writes unblock
*/
void WriteData(const std::string& data);
/** Convenience function: read a line from the socket
* @param line The line read
* @param delim The line delimiter
* @return true if a line was read
*/
bool GetNextLine(std::string& line, char delim = '\n');
/** Retrieves the current size of the send queue. */
size_t GetSendQSize() const;

View File

@ -137,16 +137,6 @@ CullResult StreamSocket::cull()
return EventHandler::cull();
}
bool StreamSocket::GetNextLine(std::string& line, char delim)
{
std::string::size_type i = recvq.find(delim);
if (i == std::string::npos)
return false;
line.assign(recvq, 0, i);
recvq.erase(0, i + 1);
return true;
}
int StreamSocket::HookChainRead(IOHook* hook, std::string& rq)
{
if (!hook)

View File

@ -155,6 +155,13 @@ class TreeSocket : public BufferedSocket
*/
std::shared_ptr<Link> AuthRemote(const CommandBase::Params& params);
/** Convenience function: read a line from the socket
* @param line The line read
* @param delim The line delimiter
* @return true if a line was read
*/
bool GetNextLine(std::string& line, char delim = '\n');
public:
const time_t age;

View File

@ -197,6 +197,16 @@ CmdResult CommandSQuit::HandleServer(TreeServer* server, CommandBase::Params& pa
return ret;
}
bool TreeSocket::GetNextLine(std::string& line, char delim)
{
std::string::size_type i = recvq.find(delim);
if (i == std::string::npos)
return false;
line.assign(recvq, 0, i);
recvq.erase(0, i + 1);
return true;
}
/** This function is called when we receive data from a remote
* server.
*/