1 /* 2 * SessionRpc.hpp 3 * 4 * Copyright (C) 2021 by RStudio, PBC 5 * 6 * Unless you have received this program directly from RStudio pursuant 7 * to the terms of a commercial license agreement with RStudio, then 8 * this program is licensed to you under the terms of version 3 of the 9 * GNU Affero General Public License. This program is distributed WITHOUT 10 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT, 11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the 12 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details. 13 * 14 */ 15 16 #ifndef SESSION_RPC_HPP 17 #define SESSION_RPC_HPP 18 19 #include <shared_core/json/Json.hpp> 20 #include <core/json/JsonRpc.hpp> 21 #include <session/SessionHttpConnection.hpp> 22 23 #include "SessionHttpMethods.hpp" 24 25 namespace rstudio { 26 namespace session { 27 namespace rpc { 28 29 void formatRpcRequest(SEXP name, 30 SEXP args, 31 core::json::JsonRpcRequest* pRequest); 32 33 void raiseJsonRpcResponseError(core::json::JsonRpcResponse& response); 34 35 void handleRpcRequest(const core::json::JsonRpcRequest& request, 36 boost::shared_ptr<HttpConnection> ptrConnection, 37 http_methods::ConnectionType connectionType); 38 39 void setRpcDelay(int delayMs); 40 41 core::Error initialize(); 42 43 bool isOfflineableRequest(boost::shared_ptr<HttpConnection> ptrConnection); 44 45 void sendJsonAsyncPendingResponse(const core::json::JsonRpcRequest &request, 46 boost::shared_ptr<HttpConnection> ptrConnection, 47 std::string &asyncHandle); 48 49 void endHandleRpcRequestIndirect( 50 const std::string& asyncHandle, 51 const core::Error& executeError, 52 core::json::JsonRpcResponse* pJsonRpcResponse); 53 54 } // namespace rpc 55 } // namespace session 56 } // namespace rstudio 57 58 #endif 59