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 562d7484e4
commit 1ed39677ce
14 changed files with 47 additions and 49 deletions

View File

@ -8,7 +8,6 @@
#include <ixwebsocket/IXNetSystem.h>
#include <ixwebsocket/IXSocketConnect.h>
#include <ixwebsocket/IXSocketFactory.h>
#include <ixwebsocket/IXSocket.h>
#include <ixwebsocket/IXCancellationRequest.h>
#include <fstream>
@ -45,16 +44,11 @@ namespace ix
SocketServer::stop();
}
void RedisServer::handleConnection(int fd, std::shared_ptr<ConnectionState> connectionState)
void RedisServer::handleConnection(std::shared_ptr<Socket> socket,
std::shared_ptr<ConnectionState> connectionState)
{
_connectedClientsCount++;
std::string errorMsg;
auto socket = createSocket(fd, errorMsg);
// Set the socket to non blocking mode + other tweaks
SocketConnect::configure(fd);
while (!_stopHandlingConnections)
{
std::vector<std::string> tokens;
@ -105,7 +99,6 @@ namespace ix
logInfo("Connection closed for connection id " + connectionState->getId());
connectionState->setTerminated();
Socket::closeSocket(fd);
_connectedClientsCount--;
}

View File

@ -42,7 +42,7 @@ namespace ix
std::atomic<bool> _stopHandlingConnections;
// Methods
virtual void handleConnection(int fd,
virtual void handleConnection(std::shared_ptr<Socket>,
std::shared_ptr<ConnectionState> connectionState) final;
virtual size_t getConnectedClientsCount() final;