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([[maybe_unused]] MythSocket *socket) override {}; // MythSocketCBs
31  void connected([[maybe_unused]] MythSocket *socket) override {}; // MythSocketCBs
32 
33  void SetThreadCount(uint count);
34 
35  void AddSocketHandler(SocketHandler *socket);
36  SocketHandler *GetConnectionBySocket(MythSocket *socket);
37 
38  void ProcessRequest(MythSocket *socket);
39 
40  void RegisterHandler(SocketRequestHandler *handler);
41  bool Listen(int port);
42 
43  public slots:
44  void newConnection(qintptr sd);
45 
46  private:
47  void ProcessRequestWork(MythSocket *socket);
48  static void HandleVersion(MythSocket *socket, const QStringList &slist);
49  static void HandleDone(MythSocket *socket);
50 
51  QMap<MythSocket*, SocketHandler*> m_socketMap;
52  QReadWriteLock m_socketLock;
53 
54  QMap<QString, SocketRequestHandler*> m_handlerMap;
55  QReadWriteLock m_handlerLock;
56 
57  MythServer *m_server { nullptr };
59 
61  QSet<MythSocket*> m_socketList;
62 };
63 #endif // MYTHSOCKETMANAGER_H
socketrequesthandler.h
MythSocketManager
Definition: mythsocketmanager.h:21
MythSocketManager::m_socketMap
QMap< MythSocket *, SocketHandler * > m_socketMap
Definition: mythsocketmanager.h:51
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:58
MythSocketCBs
Definition: mythsocket_cb.h:13
uint
unsigned int uint
Definition: compat.h:81
PROTOSERVER_PUBLIC
#define PROTOSERVER_PUBLIC
Definition: mythprotoserverexp.h:9
MythSocketManager::m_socketList
QSet< MythSocket * > m_socketList
Definition: mythsocketmanager.h:61
MythSocketManager::m_socketLock
QReadWriteLock m_socketLock
Definition: mythsocketmanager.h:52
mthreadpool.h
MythSocketManager::connected
void connected([[maybe_unused]] MythSocket *socket) override
Definition: mythsocketmanager.h:31
MThreadPool
Definition: mthreadpool.h:18
MythSocketCBs::connectionClosed
virtual void connectionClosed(MythSocket *)=0
MythSocketManager::m_handlerMap
QMap< QString, SocketRequestHandler * > m_handlerMap
Definition: mythsocketmanager.h:54
serverpool.h
SocketHandler
Definition: sockethandler.h:16
MythSocketManager::m_handlerLock
QReadWriteLock m_handlerLock
Definition: mythsocketmanager.h:55
SocketRequestHandler
Definition: socketrequesthandler.h:12
MythSocketManager::connectionFailed
void connectionFailed([[maybe_unused]] MythSocket *socket) override
Definition: mythsocketmanager.h:30
MythSocketManager::m_socketListLock
QMutex m_socketListLock
Definition: mythsocketmanager.h:60
mythsocket.h