Sha256: 3cce2a8e39ddf0aa31a92fb31cde00bf05c22fbd5d6e31423f77eca17ff65db3

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

#ifndef SUNSCRAPERRPC_H
#define SUNSCRAPERRPC_H

#include <QObject>
#include <QVector>
#include <QMap>

class SunscraperWorker;
class QLocalSocket;

class SunscraperRPC : public QObject
{
    Q_OBJECT

    enum State {
        StateHeader = 0,
        StateData,
    };

    enum Request {
        RPC_LOAD_URL  = 1,
        RPC_LOAD_HTML = 2,
        RPC_WAIT      = 3,
        RPC_FETCH     = 4,
    };

public:
    SunscraperRPC(QLocalSocket *socket);
    ~SunscraperRPC();

signals:
    void disconnected();

private slots:
    void onInputReadable();
    void onInputDisconnected();

    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;
    unsigned   m_pendingRequest, m_pendingDataLength;
    QByteArray m_buffer;

    bool       m_result;

    SunscraperRPC();

    void processRequest(unsigned requestType, QByteArray data);
    void sendReply(QByteArray data);
};

#endif // SUNSCRAPERRPC_H

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sunscraper-1.2.0 ext/standalone/sunscraperrpc.h
sunscraper-1.2.0.pre2 ext/standalone/sunscraperrpc.h
sunscraper-1.2.0.pre1 ext/standalone/sunscraperrpc.h
sunscraper-1.2.0.beta1 ext/standalone/sunscraperrpc.h