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 
52  public slots:
53  void dismiss(int idx);
54 
55  void disconnect(StreamWriterPtr sw);
56  void disconnectAll();
57 
58  bool listen();
59  void close();
60  void restart();
61 
62  private slots:
63  void acceptClient(QTcpSocket* socket, const QString& ip);
64  void rejectClient(QTcpSocket* socket, const QString& ip);
65 
66  void trackChanged(const MetaData&);
67  void serverDestroyed();
68 
69  void newClientRequest();
70  void newClientRequestError(QAbstractSocket::SocketError socketError);
71 
72  void disconnected(StreamWriter* sw);
73  void newConnection(const QString& ip);
74 
75  void activeChanged();
76  void portChanged();
77 };
78 
79 #endif
The StreamWriter class. This class is the interface between StreamDataSender and StreamServer....
Definition: StreamWriter.h:39
The StreamServer class. This class is listening for new connections and holds and administrates curre...
Definition: StreamServer.h:34
The MetaData class.
Definition: MetaData.h:45