MythTV  master
mythsocketmanager.h
Go to the documentation of this file.
1 #ifndef MYTHSOCKETMANAGER_H
2 #define MYTHSOCKETMANAGER_H
3 
4 // Qt
5 #include <QMap>
6 #include <QSet>
7 #include <QList>
8 #include <QMutex>
9 #include <QTimer>
10 #include <QReadWriteLock>
11 #include <QWaitCondition>
12 
13 // MythTV
15 #include "libmythbase/mythsocket.h"
16 #include "libmythbase/serverpool.h"
17 
18 #include "sockethandler.h"
19 #include "socketrequesthandler.h"
20 
21 class PROTOSERVER_PUBLIC MythSocketManager : public QObject, public MythSocketCBs
22 {
23  Q_OBJECT
24  public:
26  ~MythSocketManager() override;
27 
28  void readyRead(MythSocket *socket) override; // MythSocketCBs
29  void connectionClosed(MythSocket *socket) override; // MythSocketCBs
30  void connectionFailed(MythSocket *socket) override // MythSocketCBs
31  { (void)socket; }
32  void connected(MythSocket *socket) override // MythSocketCBs
33  { (void)socket; }
34 
35  void SetThreadCount(uint count);
36 
37  void AddSocketHandler(SocketHandler *socket);
38  SocketHandler *GetConnectionBySocket(MythSocket *socket);
39 
40  void ProcessRequest(MythSocket *socket);
41 
42  void RegisterHandler(SocketRequestHandler *handler);
43  bool Listen(int port);
44 
45  public slots:
46  void newConnection(qintptr sd);
47 
48  private:
49  void ProcessRequestWork(MythSocket *socket);
50  static void HandleVersion(MythSocket *socket, const QStringList &slist);
51  static void HandleDone(MythSocket *socket);
52 
53  QMap<MythSocket*, SocketHandler*> m_socketMap;
54  QReadWriteLock m_socketLock;
55 
56  QMap<QString, SocketRequestHandler*> m_handlerMap;
57  QReadWriteLock m_handlerLock;
58 
59  MythServer *m_server { nullptr };
61 
63  QSet<MythSocket*> m_socketList;
64 };
65 #endif // MYTHSOCKETMANAGER_H
socketrequesthandler.h
MythSocketManager
Definition: mythsocketmanager.h:21
MythSocketManager::m_socketMap
QMap< MythSocket *, SocketHandler * > m_socketMap
Definition: mythsocketmanager.h:53
MythSocket
Class for communcating between myth backends and frontends.
Definition: mythsocket.h:25
MythSocketCBs::readyRead
virtual void readyRead(MythSocket *)=0
MythServer
Definition: serverpool.h:131
sockethandler.h
MythSocketManager::m_threadPool
MThreadPool m_threadPool
Definition: mythsocketmanager.h:60
MythSocketCBs
Definition: mythsocket_cb.h:13
uint
unsigned int uint
Definition: compat.h:79
PROTOSERVER_PUBLIC
#define PROTOSERVER_PUBLIC
Definition: mythprotoserverexp.h:9
MythSocketManager::m_socketList
QSet< MythSocket * > m_socketList
Definition: mythsocketmanager.h:63
MythSocketManager::m_socketLock
QReadWriteLock m_socketLock
Definition: mythsocketmanager.h:54
MythSocketManager::connected
void connected(MythSocket *socket) override
Definition: mythsocketmanager.h:32
mthreadpool.h
MThreadPool
Definition: mthreadpool.h:18
MythSocketCBs::connectionClosed
virtual void connectionClosed(MythSocket *)=0
MythSocketManager::m_handlerMap
QMap< QString, SocketRequestHandler * > m_handlerMap
Definition: mythsocketmanager.h:56
MythSocketManager::connectionFailed
void connectionFailed(MythSocket *socket) override
Definition: mythsocketmanager.h:30
serverpool.h
SocketHandler
Definition: sockethandler.h:16
MythSocketManager::m_handlerLock
QReadWriteLock m_handlerLock
Definition: mythsocketmanager.h:57
SocketRequestHandler
Definition: socketrequesthandler.h:12
MythSocketManager::m_socketListLock
QMutex m_socketListLock
Definition: mythsocketmanager.h:62
mythsocket.h