18 if (pos == std::string::npos)
return std::nullopt;
20 std::string line =
_readBuf.substr(0, pos);
31 if (sent > 0)
_writeBuf.erase(0,
static_cast<size_t>(sent));
static std::string id(int n)
void flushWrite()
Try to send the buffered write data over the socket.
void setType(ClientType type)
void queueWrite(const std::string &msg)
Append msg to the write buffer (not sent until flushWrite()).
bool hasPendingWrite() const
True if there is still unsent data in the write buffer.
std::optional< std::string > nextLine()
Pop one complete ' '-terminated line, or nullopt if none buffered yet.
ClientType type() const
Client kind: PENDING until the handshake promotes it to AI or GUI.
void appendRead(std::string_view data)
Append freshly-read bytes to the read buffer.
int playerId() const
Player this connection drives (-1 for GUI / not yet assigned).