SocketServer::handleConnection takes an std::shared_ptr<Socket> instead of a file descriptor

This commit is contained in:
Benjamin Sergeant
2019-09-30 21:48:55 -07:00
parent e5c8e2e7f4
commit 313949f087
14 changed files with 47 additions and 49 deletions

View File

@@ -239,18 +239,13 @@ namespace ix
return WebSocketInitResult(true, status, "", headers, path);
}
WebSocketInitResult WebSocketHandshake::serverHandshake(int fd, int timeoutSecs)
WebSocketInitResult WebSocketHandshake::serverHandshake(int timeoutSecs)
{
_requestInitCancellation = false;
// Set the socket to non blocking mode + other tweaks
SocketConnect::configure(fd);
auto isCancellationRequested =
makeCancellationRequestWithTimeout(timeoutSecs, _requestInitCancellation);
std::string remote = std::string("remote fd ") + std::to_string(fd);
// Read first line
auto lineResult = _socket->readLine(isCancellationRequested);
auto lineValid = lineResult.first;
@@ -358,7 +353,7 @@ namespace ix
if (!_socket->writeBytes(ss.str(), isCancellationRequested))
{
return WebSocketInitResult(
false, 0, std::string("Failed sending response to ") + remote);
false, 0, std::string("Failed sending response to remote end"));
}
return WebSocketInitResult(true, 200, "", headers, uri);