PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
editor_pipe.h
1 #ifndef EDITOR_PIPE_H
2 #define EDITOR_PIPE_H
3 
4 #include <QThread>
5 #include <QVector>
6 #include <QTcpServer>
7 #include <QTcpSocket>
8 #include <QLocalSocket>
9 
10 #include <QAbstractSocket>
12 
13 #define LOCAL_SERVER_NAME "PGEEngine42e3j"
14 
15 //Q_DECLARE_METATYPE(QAbstractSocket::SocketState)
16 
17 class IntProcServer : public QTcpServer
18 {
19  Q_OBJECT
20 public:
21  explicit IntProcServer();
22  ~IntProcServer();
23 public slots:
24  void writeMessage(QString msg);
25  void stateChanged(QAbstractSocket::SocketState stat);
26 signals:
27  void messageIn(QString msg);
28 
29 protected slots:
30  void readData();
31  void handleNewConnection();
32  void clientDisconnected();
33  void displayError(QAbstractSocket::SocketError socketError);
34 
35 private:
36  QTcpSocket *clientConnection;
37 };
38 
39 
40 
41 class EditorPipe : public QThread
42 {
43  Q_OBJECT
44 public:
45  EditorPipe();
46  ~EditorPipe();
47  void shut();
48  bool isWorking;
49 
50  // SEND_LVLX: /some/path/to/level file\n\n
51  QString accepted_lvl_path; // Send to client the "READY\n\n" before accent raw data
52  bool do_acceptLevelData;
53  QString accepted_lvl_raw; // accept any raw data before will be accepted '\n\n'
54  bool do_parseLevelData;
55  LevelData accepted_lvl; // When accepted PARSE_LVLX\n\n, parse data and call signal
56  bool levelIsLoad();
57  bool sendToEditor(QString command);
58 
59 private:
60  bool levelAccepted;
61 
62 protected:
63  void run();
64  void exec();
65 
66 signals:
67  void sendMessage(QString msg);
68  //void dataReceived(QString data);
69  //void privateDataReceived(QString data, QTcpSocket *client);
70  //void showUp();
71  void openFile(QString path);
72 
73 private slots:
74  void slotOnData(QString data);
75  void icomingData(QString in);
76 
77 private:
78  bool lastMsgSuccess;
79  QString buffer;
80 };
81 
82 #endif // EDITOR_PIPE_H
~EditorPipe()
EditorPipe::~LocalServer Destructor.
Definition: editor_pipe.cpp:121
Definition: editor_pipe.h:17
Level data structure. Contains all available settings and element lists on the level.
Definition: lvl_filedata.h:396
void run()
run Initiate the thread.
Definition: editor_pipe.cpp:175
Definition: editor_pipe.h:41
void exec()
EditorPipe::exec Keeps the thread alive. Waits for incomming connections.
Definition: editor_pipe.cpp:191
PGE File Library.
EditorPipe()
EditorPipe::LocalServer Constructor.
Definition: editor_pipe.cpp:88