Issue 22: Convert remaining code to use the log module
[remote/remote-mci.git] / mcs / SessionListener.cc
blob6bf08dc27e825c0135b50f259aa921440d528de2
1 #include "SessionListener.h"
3 namespace remote { namespace mcs {
5 SessionListener::SessionListener(unsigned int port)
6 : FileDescriptor(openServerSocket(server, port, 5, 5)), sessions()
8 Log::info("Listening for client connections on port %u\n", port);
11 SessionListener::~SessionListener()
13 sessionmapbyfd_t::iterator cI;
15 for (cI = sessions.begin(); cI != sessions.end(); cI++)
16 cI->second->destroy(true);
19 void SessionListener::handleEvent(short events)
21 // for now, just try to accept a client connection
22 struct sockaddr_in client;
24 if (events & POLLIN || events & POLLPRI) {
25 int clientsock = nextClient(fd, client);
27 if (clientsock >= 0) {
28 Log::info("Accepting new client connection");
29 new Session(clientsock, sessions);