1 /* 2 * SessionHttpMethods.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_HTTP_METHODS_HPP 17 #define SESSION_HTTP_METHODS_HPP 18 19 #include <shared_core/json/Json.hpp> 20 #include <core/json/JsonRpc.hpp> 21 #include <core/WaitUtils.hpp> 22 #include <session/SessionHttpConnection.hpp> 23 #include <session/SessionModuleContext.hpp> 24 25 namespace rstudio { 26 namespace session { 27 28 class ClientEvent; 29 30 namespace http_methods { 31 32 enum ConnectionType 33 { 34 ForegroundConnection, 35 BackgroundConnection 36 }; 37 38 bool waitForMethod(const std::string& method, 39 const boost::function<void()>& initFunction, 40 const boost::function<bool()>& allowSuspend, 41 core::json::JsonRpcRequest* pRequest); 42 bool waitForMethod(const std::string& method, 43 const ClientEvent& initEvent, 44 const boost::function<bool()>& allowSuspend, 45 core::json::JsonRpcRequest* pRequest); 46 void waitForMethodInitFunction(const ClientEvent& initEvent); 47 48 bool isJsonRpcRequest(boost::shared_ptr<HttpConnection> ptrConnection); 49 50 bool isAsyncJsonRpcRequest(boost::shared_ptr<HttpConnection> ptrConnection); 51 52 void handleConnection(boost::shared_ptr<HttpConnection> ptrConnection, 53 ConnectionType connectionType); 54 boost::shared_ptr<HttpConnection> handleAsyncRpc(boost::shared_ptr<HttpConnection> ptrConnection); 55 core::WaitResult startHttpConnectionListenerWithTimeout(); 56 void registerGwtHandlers(); 57 std::string clientVersion(); 58 std::string nextSessionUrl(); 59 bool protocolDebugEnabled(); 60 core::Error initialize(); 61 62 } // namespace http_methods 63 } // namespace session 64 } // namespace rstudio 65 66 #endif 67