ext/standalone/sunscraperrpc.h in sunscraper-1.1.0.beta3 vs ext/standalone/sunscraperrpc.h in sunscraper-1.2.0.beta1

- old
+ new

@@ -5,60 +5,57 @@ #include <QVector> #include <QMap> class SunscraperWorker; class QLocalSocket; -class QTimer; class SunscraperRPC : public QObject { Q_OBJECT enum State { StateHeader = 0, StateData, }; - struct Header { - quint32 queryId; - quint32 requestType; - quint32 dataLength; - }; - enum Request { - RPC_LOAD_HTML = 1, - RPC_LOAD_URL = 2, + RPC_LOAD_URL = 1, + RPC_LOAD_HTML = 2, RPC_WAIT = 3, RPC_FETCH = 4, - RPC_DISCARD = 5, }; public: - SunscraperRPC(QString socketPath); + SunscraperRPC(QLocalSocket *socket); ~SunscraperRPC(); +signals: + void disconnected(); + private slots: void onInputReadable(); void onInputDisconnected(); - void onPageRendered(unsigned queryId, QString data); - void onTimeout(); + void onFinish(unsigned queryId); + void onTimeout(unsigned queryId); + void onFetchDone(unsigned queryId, QString data); + private: + static unsigned m_nextQueryId; + static SunscraperWorker *m_worker; + + unsigned m_queryId; QLocalSocket *m_socket; - State m_state; - Header m_pendingHeader; + State m_state; + unsigned m_pendingRequest, m_pendingDataLength; QByteArray m_buffer; - SunscraperWorker *m_worker; + bool m_result; - QList<unsigned> m_waitQueue; - QMap<unsigned, QTimer*> m_timers; - QMap<unsigned, QString> m_results; - SunscraperRPC(); - void processRequest(Header header, QByteArray data); - void sendReply(Header header, QByteArray data); + void processRequest(unsigned requestType, QByteArray data); + void sendReply(QByteArray data); }; #endif // SUNSCRAPERRPC_H