Sayonara Player
StreamServer.h
1 /* StreamServer.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef STREAM_SERVER_H
22 #define STREAM_SERVER_H
23 
24 #include "StreamWriter.h"
25 #include "Utils/Pimpl.h"
26 
27 // also needed for AcceptError
28 #include <QTcpSocket>
29 
34 class StreamServer :
35  public QObject
36 {
37  Q_OBJECT
38  PIMPL(StreamServer)
39 
40  signals:
41  void sigNewConnection(const QString& ip);
42  void sigConnectionClosed(const QString& ip);
43  void sigListening(bool);
44 
45  public:
46  explicit StreamServer(QObject* parent = nullptr);
47  ~StreamServer();
48 
49  QStringList connectedClients() const;
50 
51  public slots:
52  void dismiss(int idx);
53 
54  void disconnect(StreamWriterPtr sw);
55  void disconnectAll();
56 
57  bool listen();
58  void close();
59  void restart();
60 
61  private slots:
62  void acceptClient(QTcpSocket* socket, const QString& ip);
63  void rejectClient(QTcpSocket* socket, const QString& ip);
64 
65  void trackChanged(const MetaData&);
66  void serverDestroyed();
67 
68  void newClientRequest();
69  void newClientRequestError(QAbstractSocket::SocketError socketError);
70 
71  void disconnected(StreamWriter* sw);
72  void newConnection(const QString& ip);
73 
74  void activeChanged();
75  void portChanged();
76 };
77 
78 #endif
StreamServer
The StreamServer class. This class is listening for new connections and holds and administrates curre...
Definition: StreamServer.h:36
MetaData
The MetaData class.
Definition: MetaData.h:47
StreamWriter
The StreamWriter class. This class is the interface between StreamDataSender and StreamServer....
Definition: StreamWriter.h:41