Sayonara Player
StreamServer.h
1 /* StreamServer.h */
2 
3 /* Copyright (C) 2011-2017 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/Settings/SayonaraClass.h"
26 #include "Utils/Pimpl.h"
27 
28 #include <QThread>
29 
30 class QTcpSocket;
35 class StreamServer :
36  public QObject,
37  public SayonaraClass
38 {
39  Q_OBJECT
40  PIMPL(StreamServer)
41 
42  signals:
43  void sig_new_connection(const QString& ip);
44  void sig_connection_closed(const QString& ip);
45  void sig_listening(bool);
46 
47  public:
48  explicit StreamServer(QObject* parent=nullptr);
49  ~StreamServer();
50 
51  void active_changed();
52  void port_changed();
53 
54  public slots:
55  void dismiss(int idx);
56 
57  void disconnect(StreamWriterPtr sw);
58  void disconnect_all();
59 
60  bool listen();
61  void close();
62  void restart();
63 
64  private slots:
65  void accept_client(QTcpSocket* socket, const QString& ip);
66  void reject_client(QTcpSocket* socket, const QString& ip);
67 
68  void track_changed(const MetaData&);
69  void server_destroyed();
70 
71  void new_client_request();
72  void disconnected(StreamWriter* sw);
73  void new_connection(const QString& ip);
74 };
75 
76 #endif
The StreamWriter class. This class is the interface between StreamDataSender and StreamServer. It watches the client socket and spreads data to its client.
Definition: StreamWriter.h:39
The StreamServer class. This class is listening for new connections and holds and administrates curre...
Definition: StreamServer.h:35
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
The MetaData class.
Definition: MetaData.h:48