2006-09-03 10:39:10 +03:00
|
|
|
/*
|
2008-03-05 18:39:51 +02:00
|
|
|
Copyright (C) 2004-2008 Grame
|
|
|
|
|
2008-04-06 15:25:50 +03:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2011-02-07 17:57:10 +02:00
|
|
|
along with this program; if not, write to the Free Software
|
2008-04-06 15:25:50 +03:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
2006-09-03 10:39:10 +03:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __JackSocketServerChannel__
|
|
|
|
#define __JackSocketServerChannel__
|
|
|
|
|
|
|
|
#include "JackSocket.h"
|
2008-09-05 16:36:28 +03:00
|
|
|
#include "JackPlatformPlug.h"
|
2012-01-12 16:06:01 +02:00
|
|
|
#include "JackRequestDecoder.h"
|
|
|
|
|
2006-09-03 10:39:10 +03:00
|
|
|
#include <poll.h>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace Jack
|
|
|
|
{
|
|
|
|
|
2009-05-21 11:05:24 +03:00
|
|
|
class JackServer;
|
|
|
|
|
2006-09-03 10:39:10 +03:00
|
|
|
/*!
|
|
|
|
\brief JackServerChannel using sockets.
|
|
|
|
*/
|
|
|
|
|
2012-01-12 16:06:01 +02:00
|
|
|
class JackSocketServerChannel : public JackRunnableInterface, public JackClientHandlerInterface
|
2006-09-03 10:39:10 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2010-04-19 23:01:55 +03:00
|
|
|
JackServerSocket fRequestListenSocket; // Socket to create request socket for the client
|
2008-06-03 11:48:09 +03:00
|
|
|
JackThread fThread; // Thread to execute the event loop
|
2012-01-12 16:06:01 +02:00
|
|
|
JackRequestDecoder* fDecoder;
|
2011-02-07 17:57:10 +02:00
|
|
|
JackServer* fServer;
|
2012-01-12 16:06:01 +02:00
|
|
|
|
2010-04-19 23:01:55 +03:00
|
|
|
pollfd* fPollTable;
|
2006-09-03 10:39:10 +03:00
|
|
|
bool fRebuild;
|
|
|
|
std::map<int, std::pair<int, JackClientSocket*> > fSocketTable;
|
|
|
|
|
2008-03-05 18:39:51 +02:00
|
|
|
void BuildPoolTable();
|
|
|
|
|
2008-01-12 12:38:27 +02:00
|
|
|
void ClientCreate();
|
2007-08-16 17:50:32 +03:00
|
|
|
void ClientKill(int fd);
|
2012-01-12 16:06:01 +02:00
|
|
|
|
|
|
|
void ClientAdd(detail::JackChannelTransactionInterface* socket, JackClientOpenRequest* req, JackClientOpenResult *res);
|
|
|
|
void ClientRemove(detail::JackChannelTransactionInterface* socket, int refnum);
|
|
|
|
|
|
|
|
int GetFd(JackClientSocket* socket);
|
2008-03-05 18:39:51 +02:00
|
|
|
|
2006-09-03 10:39:10 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
JackSocketServerChannel();
|
2008-06-03 11:48:09 +03:00
|
|
|
~JackSocketServerChannel();
|
2006-09-03 10:39:10 +03:00
|
|
|
|
2009-10-23 12:47:13 +03:00
|
|
|
int Open(const char* server_name, JackServer* server); // Open the Server/Client connection
|
|
|
|
void Close(); // Close the Server/Client connection
|
2011-02-07 17:57:10 +02:00
|
|
|
|
2009-10-23 12:47:13 +03:00
|
|
|
int Start();
|
2011-08-31 12:34:38 +03:00
|
|
|
void Stop();
|
2006-09-03 10:39:10 +03:00
|
|
|
|
|
|
|
// JackRunnableInterface interface
|
2008-05-26 12:49:27 +03:00
|
|
|
bool Init();
|
2006-09-03 10:39:10 +03:00
|
|
|
bool Execute();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end of namespace
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|