Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Net.h
Go to the documentation of this file.
1//
2// Net.h
3//
4// Library: Net
5// Package: NetCore
6// Module: Net
7//
8// Basic definitions for the Poco Net library.
9// This file must be the first file included by every other Net
10// header file.
11//
12// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
13// and Contributors.
14//
15// SPDX-License-Identifier: BSL-1.0
16//
17
18
19#ifndef Net_Net_INCLUDED
20#define Net_Net_INCLUDED
21
22
23#include "Poco/Foundation.h"
24
25
26//
27// The following block is the standard way of creating macros which make exporting
28// from a DLL simpler. All files within this DLL are compiled with the Net_EXPORTS
29// symbol defined on the command line. this symbol should not be defined on any project
30// that uses this DLL. This way any other project whose source files include this file see
31// Net_API functions as being imported from a DLL, wheras this DLL sees symbols
32// defined with this macro as being exported.
33//
34#if defined(_WIN32) && defined(POCO_DLL)
35 #if defined(Net_EXPORTS)
36 #define Net_API __declspec(dllexport)
37 #else
38 #define Net_API __declspec(dllimport)
39 #endif
40#endif
41
42
43#if !defined(Net_API)
44 #if !defined(POCO_NO_GCC_API_ATTRIBUTE) && defined (__GNUC__) && (__GNUC__ >= 4)
45 #define Net_API __attribute__ ((visibility ("default")))
46 #else
47 #define Net_API
48 #endif
49#endif
50
51
52//
53// Automatically link Net library.
54//
55#if defined(_MSC_VER)
56 #if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(Net_EXPORTS)
57 #pragma comment(lib, "PocoNet" POCO_LIB_SUFFIX)
58 #endif
59#endif
60
61
62// Default to enabled IPv6 support if not explicitly disabled
63#if !defined(POCO_NET_NO_IPv6) && !defined (POCO_HAVE_IPv6)
64 #define POCO_HAVE_IPv6
65#elif defined(POCO_NET_NO_IPv6) && defined (POCO_HAVE_IPv6)
66 #undef POCO_HAVE_IPv6
67#endif // POCO_NET_NO_IPv6, POCO_HAVE_IPv6
68
69
70namespace Poco {
71namespace Net {
72
73
75 /// Initialize the network subsystem.
76 /// (Windows only, no-op elsewhere)
77
78
80 /// Uninitialize the network subsystem.
81 /// (Windows only, no-op elsewhere)
82
83
84std::string htmlize(const std::string& str);
85 /// Returns a copy of html with reserved HTML
86 /// characters (<, >, ", &) propery escaped.
87
88
89} } // namespace Poco::Net
90
91
92//
93// Automate network initialization (only relevant on Windows).
94//
95
96#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_NO_AUTOMATIC_LIB_INIT) && !defined(__GNUC__)
97
98extern "C" const struct Net_API NetworkInitializer pocoNetworkInitializer;
99
100#if defined(Net_EXPORTS)
101 #if defined(_WIN64) || (defined(_WIN32_WCE) && !defined(x86))
102 #define POCO_NET_FORCE_SYMBOL(s) __pragma(comment (linker, "/export:"#s))
103 #elif defined(_WIN32)
104 #define POCO_NET_FORCE_SYMBOL(s) __pragma(comment (linker, "/export:_"#s))
105 #endif
106#else // !Net_EXPORTS
107 #if defined(_WIN64) || (defined(_WIN32_WCE) && !defined(x86))
108 #define POCO_NET_FORCE_SYMBOL(s) __pragma(comment (linker, "/include:"#s))
109 #elif defined(_WIN32)
110 #define POCO_NET_FORCE_SYMBOL(s) __pragma(comment (linker, "/include:_"#s))
111 #endif
112#endif // Net_EXPORTS
113
114POCO_NET_FORCE_SYMBOL(pocoNetworkInitializer)
115
116#endif // POCO_OS_FAMILY_WINDOWS
117
118
119//
120// Define POCO_NET_HAS_INTERFACE for platforms that have network interface detection implemented.
121//
122#if defined(POCO_OS_FAMILY_WINDOWS) || (POCO_OS == POCO_OS_LINUX) || (POCO_OS == POCO_OS_ANDROID) || defined(POCO_OS_FAMILY_BSD) || (POCO_OS == POCO_OS_SOLARIS) || (POCO_OS == POCO_OS_QNX)
123 #define POCO_NET_HAS_INTERFACE
124#endif
125
126
127#endif // Net_Net_INCLUDED
#define ARK_API
Definition Base.h:9
#define Net_API
Definition Net.h:47
#define NetSSL_API
Definition NetSSL.h:48
#define POCO_OS_ANDROID
Definition Platform.h:41
#define POCO_OS_QNX
Definition Platform.h:37
#define POCO_OS_LINUX
Definition Platform.h:31
#define POCO_OS_SOLARIS
Definition Platform.h:36
virtual std::unique_ptr< ArkApi::ICommands > & GetCommands()=0
std::mutex RequestMutex_
Definition Requests.cpp:47
void WriteRequest(std::function< void(bool, std::string)> callback, bool success, std::string result)
Definition Requests.cpp:73
std::string GetResponse(Poco::Net::HTTPClientSession *session, Poco::Net::HTTPResponse &response)
Definition Requests.cpp:107
Poco::Net::HTTPRequest ConstructRequest(const std::string &url, Poco::Net::HTTPClientSession *&session, const std::vector< std::string > &headers, const std::string &request_type)
Definition Requests.cpp:79
std::vector< RequestData > RequestsVec_
Definition Requests.cpp:46
Requests(Requests &&)=delete
ARK_API bool CreateGetRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, std::vector< std::string > headers={})
Creates an async GET Request that runs in another thread but calls the callback from the main thread.
Definition Requests.cpp:129
ARK_API bool CreatePostRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, const std::vector< std::string > &post_ids, const std::vector< std::string > &post_data, std::vector< std::string > headers={})
Creates an async POST Request that runs in another thread but calls the callback from the main thread...
Definition Requests.cpp:238
Requests & operator=(Requests &&)=delete
ARK_API bool CreateDeleteRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, std::vector< std::string > headers={})
Creates an async DELETE Request that runs in another thread but calls the callback from the main thre...
Definition Requests.cpp:292
Requests & operator=(const Requests &)=delete
ARK_API bool CreatePostRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, const std::string &post_data, std::vector< std::string > headers={})
Creates an async POST Request with application/x-www-form-urlencoded content type that runs in anothe...
Definition Requests.cpp:162
static ARK_API Requests & Get()
Definition Requests.cpp:67
ARK_API bool CreatePostRequest(const std::string &url, const std::function< void(bool, std::string)> &callback, const std::string &post_data, const std::string &content_type, std::vector< std::string > headers={})
Creates an async POST Request that runs in another thread but calls the callback from the main thread...
Definition Requests.cpp:200
std::unique_ptr< impl > pimpl
Definition Requests.h:84
Requests(const Requests &)=delete
virtual void AddOnTickCallback(const FString &id, const std::function< void(float)> &callback)=0
Added function will be called every frame.
virtual bool RemoveOnTickCallback(const FString &id)=0
Removes a on-tick callback.
Definition Logger.h:9
static std::shared_ptr< spdlog::logger > & GetLog()
Definition Logger.h:22
std::string displayText() const
Returns the exception code if defined.
virtual std::istream & receiveResponse(HTTPResponse &response)
virtual std::ostream & sendRequest(HTTPRequest &request)
Returns the connection timeout for HTTP connections.
static const std::string HTTP_1_1
void setContentLength(std::streamsize length)
Returns the HTTP version for this message.
HTTPRequest(const std::string &method, const std::string &uri, const std::string &version)
Creates a HTTP/1.0 request with the given method and URI.
static const std::string HTTP_GET
static const std::string HTTP_DELETE
static const std::string HTTP_POST
const std::string & getReason() const
Sets the HTTP reason phrase.
HTTPResponse(HTTPStatus status)
HTTPStatus getStatus() const
HTTPSClientSession(const std::string &host, Poco::UInt16 port, Context::Ptr pContext, Session::Ptr pSession)
std::string proxyRequestPrefix() const
Sends the given HTTPRequest over an existing connection.
HTTPSClientSession(Context::Ptr pContext, Session::Ptr pSession)
HTTPSClientSession(Context::Ptr pContext)
Creates a HTTPSClientSession using the given host and port.
void proxyAuthenticate(HTTPRequest &request)
Checks if we can reuse a persistent connection.
int read(char *buffer, std::streamsize length)
HTTPSClientSession(const HTTPSClientSession &)
void connect(const SocketAddress &address)
Refills the internal buffer.
HTTPSClientSession(const SecureStreamSocket &socket, Session::Ptr pSession)
X509Certificate serverCertificate()
HTTPSClientSession & operator=(const HTTPSClientSession &)
HTTPSClientSession(const std::string &host, Poco::UInt16 port=HTTPS_PORT)
HTTPSClientSession(const SecureStreamSocket &socket)
Creates an unconnected HTTPSClientSession.
HTTPSClientSession(const std::string &host, Poco::UInt16 port, Context::Ptr pContext)
RejectCertificateHandler(bool handleErrorsOnServerSide)
void initializeClient(PrivateKeyPassphraseHandlerPtr ptrPassphraseHandler, InvalidCertificateHandlerPtr ptrHandler, Context::Ptr ptrContext)
static SSLManager & instance()
This stream discards all characters written to it.
Definition NullStream.h:77
static std::streamsize copyStream(std::istream &istr, std::ostream &ostr, std::size_t bufferSize=8192)
const std::string & getHost() const
Sets the user-info part of the URI.
Definition URI.h:385
const std::string & getScheme() const
Definition URI.h:373
URI(const std::string &uri)
Creates an empty URI.
unsigned short getPort() const
Sets the host part of the URI.
std::string getPathAndQuery() const
Returns the encoded path, query and fragment parts of the URI.
void error(const T &)
Definition IBaseApi.h:9
std::unique_ptr< IBaseApi > game_api
Definition IBaseApi.h:25
void NetSSL_API initializeSSL()
void Net_API uninitializeNetwork()
void Net_API initializeNetwork()
void NetSSL_API uninitializeSSL()
Definition format.h:408
Definition json.hpp:4518
std::function< void(bool, std::string)> callback
Definition Requests.cpp:41
static std::string escape(const std::string &s, bool strictJSON=false)