| 95 | }; |
| 96 | |
| 97 | class JSONRPCRequest |
| 98 | { |
| 99 | public: |
| 100 | UniValue id; |
| 101 | std::string strMethod; |
| 102 | UniValue params; |
| 103 | bool fHelp; |
| 104 | std::string URI; |
| 105 | std::string authUser; |
| 106 | |
| 107 | bool isLongPolling; |
| 108 | |
| 109 | /** |
| 110 | * If using batch JSON request, this object won't get the underlying HTTPRequest. |
| 111 | */ |
| 112 | JSONRPCRequest() { |
| 113 | id = NullUniValue; |
| 114 | params = NullUniValue; |
| 115 | fHelp = false; |
| 116 | req = NULL; |
| 117 | isLongPolling = false; |
| 118 | }; |
| 119 | |
| 120 | JSONRPCRequest(HTTPRequest *_req); |
| 121 | |
| 122 | /** |
| 123 | * Start long-polling |
| 124 | */ |
| 125 | void PollStart(); |
| 126 | |
| 127 | /** |
| 128 | * Ping long-poll connection with an empty character to make sure it's still alive. |
| 129 | */ |
| 130 | void PollPing(); |
| 131 | |
| 132 | /** |
| 133 | * Returns whether the underlying long-poll connection is still alive. |
| 134 | */ |
| 135 | bool PollAlive(); |
| 136 | |
| 137 | /** |
| 138 | * End a long poll request. |
| 139 | */ |
| 140 | void PollCancel(); |
| 141 | |
| 142 | /** |
| 143 | * Return the JSON result of a long poll request |
| 144 | */ |
| 145 | void PollReply(const UniValue& result); |
| 146 | |
| 147 | void parse(const UniValue& valRequest); |
| 148 | |
| 149 | // FIXME: make this private? |
| 150 | HTTPRequest *req; |
| 151 | }; |
| 152 | /** Query whether RPC is running */ |
| 153 | bool IsRPCRunning(); |
| 154 | |