| 51 | }; |
| 52 | |
| 53 | class CProtocol |
| 54 | { |
| 55 | class CShared |
| 56 | { |
| 57 | public: |
| 58 | CShared(std::shared_ptr<CGlobal> pGlobal) : |
| 59 | m_pGlobal(std::move(pGlobal)) |
| 60 | { |
| 61 | } |
| 62 | |
| 63 | std::shared_ptr<CGlobal> m_pGlobal; |
| 64 | CLock m_Lock; |
| 65 | int m_NumTotalRequests GUARDED_BY(m_Lock) = 0; |
| 66 | int m_LatestResponseStatus GUARDED_BY(m_Lock) = STATUS_NONE; |
| 67 | int m_LatestResponseIndex GUARDED_BY(m_Lock) = -1; |
| 68 | }; |
| 69 | |
| 70 | class CJob : public IJob |
| 71 | { |
| 72 | int m_Protocol; |
| 73 | int m_ServerPort; |
| 74 | int m_Index; |
| 75 | int m_InfoSerial; |
| 76 | std::shared_ptr<CShared> m_pShared; |
| 77 | std::shared_ptr<CHttpRequest> m_pRegister; |
| 78 | IHttp *m_pHttp; |
| 79 | void Run() override; |
| 80 | |
| 81 | public: |
| 82 | CJob(int Protocol, int ServerPort, int Index, int InfoSerial, std::shared_ptr<CShared> pShared, std::shared_ptr<CHttpRequest> &&pRegister, IHttp *pHttp) : |
| 83 | m_Protocol(Protocol), |
| 84 | m_ServerPort(ServerPort), |
| 85 | m_Index(Index), |
| 86 | m_InfoSerial(InfoSerial), |
| 87 | m_pShared(std::move(pShared)), |
| 88 | m_pRegister(std::move(pRegister)), |
| 89 | m_pHttp(pHttp) |
| 90 | { |
| 91 | } |
| 92 | ~CJob() override = default; |
| 93 | }; |
| 94 | |
| 95 | CRegister *m_pParent; |
| 96 | int m_Protocol; |
| 97 | |
| 98 | std::shared_ptr<CShared> m_pShared; |
| 99 | bool m_NewChallengeToken = false; |
| 100 | bool m_HaveChallengeToken = false; |
| 101 | char m_aChallengeToken[128] = {0}; |
| 102 | |
| 103 | void CheckChallengeStatus(); |
| 104 | |
| 105 | public: |
| 106 | int64_t m_PrevRegister = -1; |
| 107 | int64_t m_NextRegister = -1; |
| 108 | |
| 109 | CProtocol(CRegister *pParent, int Protocol); |
| 110 | void OnToken(const char *pToken); |