SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ServerConnection.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2018 SEGS Team (see Authors.txt)
5  * This software is licensed! (See License.txt for details)
6  */
7 
8 #ifndef SERVERCONNECTION_H
9 #define SERVERCONNECTION_H
10 
11 #include <QObject>
12 #include <unordered_map>
13 
14 class QNetworkAccessManager;
15 class QNetworkReply;
16 class QIODevice;
17 struct ProjectApp;
18 struct ProjectList;
19 class AppVersionManifest;
20 
22 {
23  QNetworkReply * reply;
24  QString requested_url;
25  QIODevice *target;
27 };
28 class ServerConnection : public QObject
29 {
30  Q_OBJECT
31  QString m_base_url;
32  std::map< QNetworkReply *,OperationData> m_operations_in_flight;
33  QNetworkAccessManager *m_network_manager;
34 public:
35  explicit ServerConnection(const QString &baseUrl,QObject *parent = 0);
36 
37 signals:
38  void downloadProgress(const QString &req_url,qint64 bytesReceived, qint64 bytesTotal);
39  void networkFailure(const QString &msg);
40 
41  void retrievedManifest(QString req_url,QString manifestData);
42  void appDataAvailable(ProjectApp *app_data);
43  void projectListAvailable(ProjectList *projects);
44  void manifestAvailable(AppVersionManifest *projects);
45 private slots:
46  void httpDownloadFinished(QNetworkReply *);
47  void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
48 
49  // void onAppDataRequested(QString req_url)
50 public slots:
51  void onRequestProjectList(); // should be called periodically to refresh the server list ( 1/minute ? )
52  void onRequestAppData(); // called at app startup to download slav.app_data
53  void onRequestManifest(const QString &manifestname);
54  void onRequestFileList(const QString &base_path,const QStringList &files);
55 };
56 
57 #endif // SERVERCONNECTION_H
int targetType
Definition: ServerConnection.h:26
void onRequestFileList(const QString &base_path, const QStringList &files)
Definition: ServerConnection.cpp:37
void manifestAvailable(AppVersionManifest *projects)
Definition: ProjectManifest.h:28
void retrievedManifest(QString req_url, QString manifestData)
void appDataAvailable(ProjectApp *app_data)
void projectListAvailable(ProjectList *projects)
Definition: ProjectDescriptor.h:60
ServerConnection(const QString &baseUrl, QObject *parent=0)
Definition: ServerConnection.cpp:22
void onRequestManifest(const QString &manifestname)
Definition: ServerConnection.cpp:28
Definition: ServerConnection.h:21
void downloadProgress(const QString &req_url, qint64 bytesReceived, qint64 bytesTotal)
Definition: ProjectDescriptor.h:43
QIODevice * target
Definition: ServerConnection.h:25
QString requested_url
Definition: ServerConnection.h:24
Definition: ServerConnection.h:28
void onRequestProjectList()
Definition: ServerConnection.cpp:84
void networkFailure(const QString &msg)
void onRequestAppData()
Definition: ServerConnection.cpp:89
QNetworkReply * reply
Definition: ServerConnection.h:23