Optimized Request and Response classes.
This commit is contained in:
@@ -24,9 +24,9 @@ namespace ehs
|
||||
bool connected;
|
||||
|
||||
public:
|
||||
static const UInt_16 HTTPS_Port = 443;
|
||||
static const UInt_16 HTTP_Port = 80;
|
||||
static const UInt_16 MaxHeaderSize = 8192;
|
||||
static constexpr UInt_16 HTTPS_Port = 443;
|
||||
static constexpr UInt_16 HTTP_Port = 80;
|
||||
static constexpr UInt_16 MaxHeaderSize = 8192;
|
||||
|
||||
virtual ~BaseTCP() = default;
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace ehs
|
||||
/// @param [in] address The ip address to bind to.
|
||||
/// @param [in] port The port to bind to.
|
||||
/// @note Used for servers.
|
||||
virtual void Bind(const Str_8& address, UInt_16 port) = 0;
|
||||
virtual void Bind(Str_8 address, const UInt_16 &port) = 0;
|
||||
|
||||
/// Listens for new incoming connections.
|
||||
/// @note Used for servers.
|
||||
@@ -63,13 +63,13 @@ namespace ehs
|
||||
|
||||
/// Accepts the new incoming connection.
|
||||
/// @note Used for servers.
|
||||
virtual BaseTCP* Accept() = 0;
|
||||
virtual BaseTCP *Accept() = 0;
|
||||
|
||||
/// Connects to a server at the specified address and port.
|
||||
/// @param [in] address The ip address to connect to.
|
||||
/// @param [in] port The port to connect to.
|
||||
/// @note Used for clients.
|
||||
virtual void Connect(const Str_8& address, UInt_16 port) = 0;
|
||||
virtual void Connect(Str_8 address, const UInt_16 &port) = 0;
|
||||
|
||||
/// Sends data to the connected endpoint.
|
||||
/// @param [in] buffer The data to send to the endpoint.
|
||||
|
45
include/ehs/io/socket/HeaderVar.h
Normal file
45
include/ehs/io/socket/HeaderVar.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/Str.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class HeaderVar
|
||||
{
|
||||
private:
|
||||
UInt_64 id;
|
||||
Str_8 name;
|
||||
Str_8 value;
|
||||
|
||||
public:
|
||||
HeaderVar();
|
||||
|
||||
HeaderVar(Str_8 name, Str_8 value);
|
||||
|
||||
HeaderVar(HeaderVar &&other) noexcept;
|
||||
|
||||
HeaderVar(const HeaderVar &other);
|
||||
|
||||
HeaderVar &operator=(HeaderVar &&other) noexcept;
|
||||
|
||||
HeaderVar &operator=(const HeaderVar &other);
|
||||
|
||||
bool operator==(const HeaderVar &other) const;
|
||||
|
||||
bool operator!=(const HeaderVar &other) const;
|
||||
|
||||
bool operator==(const UInt_64 &otherId) const;
|
||||
|
||||
bool operator!=(const UInt_64 &otherId) const;
|
||||
|
||||
UInt_64 GetId() const;
|
||||
|
||||
Str_8 GetName() const;
|
||||
|
||||
Str_8 GetValue() const;
|
||||
|
||||
void SetValue(Str_8 value);
|
||||
|
||||
Str_8 ToStr() const;
|
||||
};
|
||||
}
|
45
include/ehs/io/socket/QueryVar.h
Normal file
45
include/ehs/io/socket/QueryVar.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/Str.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class QueryVar
|
||||
{
|
||||
private:
|
||||
UInt_64 id;
|
||||
Str_8 name;
|
||||
Str_8 value;
|
||||
|
||||
public:
|
||||
QueryVar();
|
||||
|
||||
QueryVar(Str_8 name, Str_8 value);
|
||||
|
||||
QueryVar(QueryVar &&other) noexcept;
|
||||
|
||||
QueryVar(const QueryVar &other);
|
||||
|
||||
QueryVar &operator=(QueryVar &&other) noexcept;
|
||||
|
||||
QueryVar &operator=(const QueryVar &other);
|
||||
|
||||
bool operator==(const QueryVar &other) const;
|
||||
|
||||
bool operator!=(const QueryVar &other) const;
|
||||
|
||||
bool operator==(const UInt_64 &otherId) const;
|
||||
|
||||
bool operator!=(const UInt_64 &otherId) const;
|
||||
|
||||
UInt_64 GetId() const;
|
||||
|
||||
Str_8 GetName() const;
|
||||
|
||||
Str_8 GetValue() const;
|
||||
|
||||
void SetValue(Str_8 value);
|
||||
|
||||
Str_8 ToStr() const;
|
||||
};
|
||||
}
|
@@ -5,6 +5,8 @@
|
||||
#include "ehs/Str.h"
|
||||
#include "ehs/json/Json.h"
|
||||
#include "Socket.h"
|
||||
#include "QueryVar.h"
|
||||
#include "HeaderVar.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
@@ -21,8 +23,8 @@ namespace ehs
|
||||
private:
|
||||
Verb verb;
|
||||
Str_8 rsrc;
|
||||
Vector<Str_8> queries;
|
||||
Vector<Str_8> header;
|
||||
Vector<QueryVar> queries;
|
||||
Vector<HeaderVar> header;
|
||||
ContentType cType;
|
||||
Str_8 body;
|
||||
|
||||
@@ -33,25 +35,34 @@ namespace ehs
|
||||
/// Initializes this request with a given verb and URI resource.
|
||||
/// @param [in] verb The type of request to make.
|
||||
/// @param [in] rsrc The URI endpoint to make the request at.
|
||||
Request(const Verb verb, const Str_8& rsrc);
|
||||
Request(const Verb &verb, Str_8 rsrc);
|
||||
|
||||
/// Initializes this request with the raw request data.
|
||||
/// @param [in] data The C-style string of the request.
|
||||
/// @param [in] size The size of the given C-style string.
|
||||
Request(const char* data, const UInt_64 size);
|
||||
Request(const char *data, const UInt_64 &size);
|
||||
|
||||
/// Initializes this request with the raw request data.
|
||||
/// @param [in] data The string of the request.
|
||||
Request(const Str_8& data);
|
||||
Request(const Str_8 &data);
|
||||
|
||||
/// Moves members from another object of the same type.
|
||||
/// @param [in] other The object to move from.
|
||||
Request(Request &&other) noexcept;
|
||||
|
||||
/// Copies members from another object of the same type.
|
||||
/// @param [in] req The object to copy from.
|
||||
Request(const Request& req) = default;
|
||||
/// @param [in] other The object to copy from.
|
||||
Request(const Request &other);
|
||||
|
||||
/// Moves members from another object of the same type.
|
||||
/// @param [in] other The object to move from.
|
||||
/// @returns The request that has been assigned to.
|
||||
Request& operator=(Request &&other) noexcept;
|
||||
|
||||
/// Copies members from another object of the same type.
|
||||
/// @param [in] req The object to copy from.
|
||||
/// @param [in] other The object to copy from.
|
||||
/// @returns The request that has been assigned to.
|
||||
Request& operator=(const Request& req);
|
||||
Request& operator=(const Request &other);
|
||||
|
||||
/// Retrieves the verb for the request.
|
||||
/// @returns The result.
|
||||
@@ -59,7 +70,7 @@ namespace ehs
|
||||
|
||||
/// Sets the content type for the body.
|
||||
/// @param [in] cType The content type to use.
|
||||
void SetContentType(const ContentType cType);
|
||||
void SetContentType(const ContentType &cType);
|
||||
|
||||
/// Retrieves the content type for the body.
|
||||
/// @returns The result.
|
||||
@@ -67,75 +78,145 @@ namespace ehs
|
||||
|
||||
/// Sets the URI resource.
|
||||
/// @param [in] rsrc The resource.
|
||||
void SetResource(const Str_8& rsrc);
|
||||
void SetResource(Str_8 rsrc);
|
||||
|
||||
/// Retrieves the URI resource.
|
||||
/// @returns The result.
|
||||
Str_8 GetResource() const;
|
||||
|
||||
/// Adds a query variable to the URI.
|
||||
/// @param [in] var The variable identifier.
|
||||
/// @param [in] value The value of the variable.
|
||||
void AddQuery(const Str_8& var, const Str_8& value);
|
||||
/// Checks whether a header variable exists using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns True if the variable exists. False otherwise.
|
||||
bool HasQueryVar(const UInt_64 &id) const;
|
||||
|
||||
/// Retrieves a query variable from the URI.
|
||||
/// @param [in] var The variable identifier to look for.
|
||||
/// @returns The value of the query variable. Empty if it was not found.
|
||||
Str_8 GetQuery(const Str_8& var);
|
||||
/// Checks whether a header variable exists using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns True if the variable exists. False otherwise.
|
||||
bool HasQueryVar(const Str_8 &name) const;
|
||||
|
||||
/// Adds a header variable.
|
||||
/// @param [in] var The variable to add to the header.
|
||||
/// @returns False if the given variable name already exists. True otherwise.
|
||||
bool AddQueryVar(QueryVar var);
|
||||
|
||||
/// Removes a header variable using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns True if the variable was found. False otherwise.
|
||||
bool RemoveQueryVar(const UInt_64 &id);
|
||||
|
||||
/// Removes a header variable using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns True if the variable was found. False otherwise.
|
||||
bool RemoveQueryVar(const Str_8 &name);
|
||||
|
||||
/// Retrieves a header variable using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns The variable object if found. Nullptr otherwise.
|
||||
QueryVar *GetQueryVar(const UInt_64 &id) const;
|
||||
|
||||
/// Retrieves a header variable using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns The variable object if found. Nullptr otherwise.
|
||||
QueryVar *GetQueryVar(const Str_8& name) const;
|
||||
|
||||
/// Retrieves a header variable value using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns The variable's value if found. Empty otherwise.
|
||||
Str_8 GetQueryValue(const UInt_64 &id) const;
|
||||
|
||||
/// Retrieves a header variable value using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns The variable's value if found. Empty otherwise.
|
||||
Str_8 GetQueryValue(const Str_8& name) const;
|
||||
|
||||
/// Retrieves all the query variables from the URI in a vector object.
|
||||
/// @returns The result.
|
||||
Vector<Str_8> GetQueries() const;
|
||||
Vector<QueryVar> GetQueries() const;
|
||||
|
||||
/// A helper method to automatically add the required header variables for basic authentication.
|
||||
/// @param [in] id The username or id.
|
||||
/// @param [in] secret The secret given by an API.
|
||||
void BasicAuth(const Str_8& id, const Str_8& secret);
|
||||
void BasicAuth(const Str_8 &id, const Str_8 &secret);
|
||||
|
||||
/// A helper method to automatically add the required header variables for bearer authentication.
|
||||
/// @param [in] token The token given by an API.
|
||||
void BearerAuth(const Str_8& token);
|
||||
void BearerAuth(const Str_8 &token);
|
||||
|
||||
/// A helper method to automatically add the required header variables for bearer authentication.
|
||||
/// @param [in] token The token given by an API.
|
||||
/// @param [in] clientId The client id given by an API.
|
||||
void BearerAuth(const Str_8& token, const Str_8& clientId);
|
||||
void BearerAuth(const Str_8 &token, const Str_8 &clientId);
|
||||
|
||||
/// A helper method to automatically add the required header variables for bot authentication.
|
||||
/// @param [in] token The token given by an API.
|
||||
void BotAuth(const Str_8& token);
|
||||
void BotAuth(const Str_8 &token);
|
||||
|
||||
/// Checks whether a header variable exists using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns True if the variable exists. False otherwise.
|
||||
bool HasHeaderVar(const UInt_64 &id) const;
|
||||
|
||||
/// Checks whether a header variable exists using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns True if the variable exists. False otherwise.
|
||||
bool HasHeaderVar(const Str_8 &name) const;
|
||||
|
||||
/// Adds a header variable.
|
||||
/// @param [in] var The variable identifier.
|
||||
/// @param [in] value The value of the variable.
|
||||
void AddToHeader(const Str_8& var, const Str_8& value);
|
||||
/// @param [in] var The variable to add to the header.
|
||||
/// @returns False if the given variable name already exists. True otherwise.
|
||||
bool AddHeaderVar(HeaderVar var);
|
||||
|
||||
/// Retrieves a header variable.
|
||||
/// @param [in] var The variable identifier to look for.
|
||||
/// @returns The value of the header variable. Empty if it was not found.
|
||||
Str_8 GetHeader(const Str_8& var) const;
|
||||
/// Removes a header variable using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns True if the variable was found. False otherwise.
|
||||
bool RemoveHeaderVar(const UInt_64 &id);
|
||||
|
||||
/// Removes a header variable using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns True if the variable was found. False otherwise.
|
||||
bool RemoveHeaderVar(const Str_8 &name);
|
||||
|
||||
/// Retrieves a header variable using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns The variable object if found. Nullptr otherwise.
|
||||
HeaderVar *GetHeaderVar(const UInt_64 &id) const;
|
||||
|
||||
/// Retrieves a header variable using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns The variable object if found. Nullptr otherwise.
|
||||
HeaderVar *GetHeaderVar(const Str_8& name) const;
|
||||
|
||||
/// Retrieves a header variable value using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns The variable's value if found. Empty otherwise.
|
||||
Str_8 GetHeaderValue(const UInt_64 &id) const;
|
||||
|
||||
/// Retrieves a header variable value using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns The variable's value if found. Empty otherwise.
|
||||
Str_8 GetHeaderValue(const Str_8& name) const;
|
||||
|
||||
/// Retrieves all the header variables in a vector object.
|
||||
/// @returns The result.
|
||||
Vector<Str_8> GetHeader() const;
|
||||
Vector<HeaderVar> GetHeader() const;
|
||||
|
||||
/// Adds a body variable.
|
||||
/// @param [in] var The variable identifier.
|
||||
/// @param [in] value The value of the variable.
|
||||
void AddToBody(const Str_8& var, const Str_8& value);
|
||||
void AddToBody(const Str_8 &var, const Str_8 &value);
|
||||
|
||||
/// Adds a value to the body.
|
||||
/// @param [in] data The value to add.
|
||||
void AddToBody(const Str_8& data);
|
||||
void AddToBody(const Str_8 &data);
|
||||
|
||||
/// Sets the entire body.
|
||||
/// @param [in] body The body to use.
|
||||
void SetBody(const Str_8& body);
|
||||
void SetBody(const Str_8 &body);
|
||||
|
||||
/// Retrieves a body variable.
|
||||
/// @param [in] var The variable identifier to look for.
|
||||
/// @returns The value of the body variable. Empty if it was not found.
|
||||
Str_8 GetVar(const Str_8& var) const;
|
||||
Str_8 GetVar(const Str_8 &var) const;
|
||||
|
||||
/// Retrieves the entire body.
|
||||
/// @returns The result.
|
||||
@@ -152,13 +233,13 @@ namespace ehs
|
||||
bool IsValid() const;
|
||||
|
||||
private:
|
||||
static Str_8 VerbToStr(const Verb verb);
|
||||
static Str_8 VerbToStr(const Verb &verb);
|
||||
|
||||
static Str_8 ContentTypeToStr(const ContentType cType);
|
||||
static Str_8 ContentTypeToStr(const ContentType &cType);
|
||||
|
||||
static ContentType StrToContentType(const Str_8& value);
|
||||
static ContentType StrToContentType(const Str_8 &value);
|
||||
|
||||
void ReadData(const Str_8& data);
|
||||
void ReadData(const Str_8 &data);
|
||||
|
||||
};
|
||||
}
|
@@ -5,6 +5,7 @@
|
||||
#include "ehs/Str.h"
|
||||
#include "ehs/json/Json.h"
|
||||
#include "Socket.h"
|
||||
#include "HeaderVar.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
@@ -14,7 +15,7 @@ namespace ehs
|
||||
UInt_32 code;
|
||||
Str_8 server;
|
||||
ContentType cType;
|
||||
Vector<Str_8> header;
|
||||
Vector<HeaderVar> header;
|
||||
Str_8 body;
|
||||
|
||||
public:
|
||||
@@ -24,29 +25,38 @@ namespace ehs
|
||||
/// Initializes this response with a given code and server identifier.
|
||||
/// @param [in] code The code to give.
|
||||
/// @param [in] server The server identifier.
|
||||
Response(const UInt_32 code, const Str_8& server);
|
||||
Response(const UInt_32 &code, Str_8 server);
|
||||
|
||||
/// Initializes this response with the raw response data.
|
||||
/// @param [in] data The C-style string of the response.
|
||||
/// @param [in] size The size of the given C-style string.
|
||||
Response(const char* data, const UInt_64 size);
|
||||
Response(const char *data, const UInt_64 &size);
|
||||
|
||||
/// Initializes this response with the raw response data.
|
||||
/// @param [in] data The string of the response.
|
||||
Response(const Str_8& data);
|
||||
Response(const Str_8 &data);
|
||||
|
||||
/// Moves members from another object of the same type.
|
||||
/// @param [in] other The object to move from.
|
||||
Response(Response &&other) noexcept;
|
||||
|
||||
/// Copies members from another object of the same type.
|
||||
/// @param [in] res The object to copy from.
|
||||
Response(const Response& res) = default;
|
||||
/// @param [in] other The object to copy from.
|
||||
Response(const Response &other);
|
||||
|
||||
/// Moves members from another object of the same type.
|
||||
/// @param [in] other The object to move from.
|
||||
/// @returns The response that has been assigned to.
|
||||
Response &operator=(Response &&other) noexcept;
|
||||
|
||||
/// Copies members from another object of the same type.
|
||||
/// @param [in] res The object to copy from.
|
||||
/// @returns The response that has been assigned to.
|
||||
Response& operator=(const Response& res);
|
||||
Response& operator=(const Response &other);
|
||||
|
||||
/// Sets the response code to send to the endpoint.
|
||||
/// @param [in] code The code for success, error or info.
|
||||
void SetCode(const UInt_32 code);
|
||||
void SetCode(const UInt_32 &code);
|
||||
|
||||
/// Retrieves the response code.
|
||||
/// @returns The result.
|
||||
@@ -54,7 +64,7 @@ namespace ehs
|
||||
|
||||
/// Sets the server identifier.
|
||||
/// @param [in] server The server identifier to use.
|
||||
void SetServer(const Str_8& server);
|
||||
void SetServer(Str_8 server);
|
||||
|
||||
/// Retrieves the server identifier.
|
||||
/// @returns The result.
|
||||
@@ -62,25 +72,60 @@ namespace ehs
|
||||
|
||||
/// Sets the content type for the body.
|
||||
/// @param [in] cType The content type to use.
|
||||
void SetContentType(const ContentType cType);
|
||||
void SetContentType(const ContentType &cType);
|
||||
|
||||
/// Retrieves the content type for the body.
|
||||
/// @returns The result.
|
||||
ContentType GetContentType() const;
|
||||
|
||||
/// Adds a header variable.
|
||||
/// @param [in] var The variable identifier.
|
||||
/// @param [in] value The value of the variable.
|
||||
void AddToHeader(const Str_8& var, const Str_8& value);
|
||||
/// Checks whether a header variable exists using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns True if the variable exists. False otherwise.
|
||||
bool HasHeaderVar(const UInt_64 &id) const;
|
||||
|
||||
/// Retrieves a header variable.
|
||||
/// @param [in] var The variable identifier to look for.
|
||||
/// @returns The value of the header variable. Empty if it was not found.
|
||||
Str_8 GetHeader(const Str_8& var) const;
|
||||
/// Checks whether a header variable exists using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns True if the variable exists. False otherwise.
|
||||
bool HasHeaderVar(const Str_8 &name) const;
|
||||
|
||||
/// Adds a header variable.
|
||||
/// @param [in] var The variable to add to the header.
|
||||
/// @returns False if the given variable name already exists. True otherwise.
|
||||
bool AddHeaderVar(HeaderVar var);
|
||||
|
||||
/// Removes a header variable using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns True if the variable was found. False otherwise.
|
||||
bool RemoveHeaderVar(const UInt_64 &id);
|
||||
|
||||
/// Removes a header variable using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns True if the variable was found. False otherwise.
|
||||
bool RemoveHeaderVar(const Str_8 &name);
|
||||
|
||||
/// Retrieves a header variable using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns The variable object if found. Nullptr otherwise.
|
||||
HeaderVar *GetHeaderVar(const UInt_64 &id) const;
|
||||
|
||||
/// Retrieves a header variable using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns The variable object if found. Nullptr otherwise.
|
||||
HeaderVar *GetHeaderVar(const Str_8& name) const;
|
||||
|
||||
/// Retrieves a header variable value using the id.
|
||||
/// @param [in] id The variable id to look for.
|
||||
/// @returns The variable's value if found. Empty otherwise.
|
||||
Str_8 GetHeaderValue(const UInt_64 &id) const;
|
||||
|
||||
/// Retrieves a header variable value using the name.
|
||||
/// @param [in] name The variable name to look for.
|
||||
/// @returns The variable's value if found. Empty otherwise.
|
||||
Str_8 GetHeaderValue(const Str_8& name) const;
|
||||
|
||||
/// Retrieves all the header variables in a vector object.
|
||||
/// @returns The result.
|
||||
Vector<Str_8> GetHeader() const;
|
||||
Vector<HeaderVar> GetHeader() const;
|
||||
|
||||
/// Adds a body variable.
|
||||
/// @param [in] var The variable identifier.
|
||||
@@ -115,13 +160,13 @@ namespace ehs
|
||||
bool IsValid() const;
|
||||
|
||||
private:
|
||||
static Str_8 CodeToStr(const UInt_32 code);
|
||||
static Str_8 CodeToStr(const UInt_32 &code);
|
||||
|
||||
static Str_8 ContentTypeToStr(const ContentType cType);
|
||||
static Str_8 ContentTypeToStr(const ContentType &cType);
|
||||
|
||||
static ContentType StrToContentType(const Str_8& value);
|
||||
static ContentType StrToContentType(const Str_8 &value);
|
||||
|
||||
void ReadData(const Str_8& data);
|
||||
void ReadData(const Str_8 &data);
|
||||
|
||||
};
|
||||
}
|
@@ -42,17 +42,15 @@ namespace ehs
|
||||
|
||||
void Release() override;
|
||||
|
||||
void Bind(const Str_8& address, unsigned short port) override;
|
||||
|
||||
void Listen() override;
|
||||
|
||||
SSL* Accept() override;
|
||||
|
||||
void Connect(const Str_8& address, const UInt_16 port) override;
|
||||
void Connect(Str_8 address, const UInt_16 &port) override;
|
||||
|
||||
UInt_64 Send(const Byte* const buffer, const UInt_32 size) override;
|
||||
UInt_64 Send(const Byte* buffer, const UInt_32 size) override;
|
||||
|
||||
UInt_64 Receive(Byte* const buffer, const UInt_32 size) override;
|
||||
UInt_64 Receive(Byte* buffer, const UInt_32 size) override;
|
||||
|
||||
void UseCertificate(const Char_8* data, const UInt_32 &size);
|
||||
|
||||
|
@@ -40,6 +40,7 @@ namespace ehs
|
||||
APP_XML,
|
||||
TEXT_PLAIN,
|
||||
TEXT_HTML,
|
||||
TEXT_CSS,
|
||||
TEXT_XML,
|
||||
IMG_X_ICON,
|
||||
NONE
|
||||
|
@@ -46,7 +46,7 @@ namespace ehs
|
||||
/// @param [in] address The local IPv4 or IPv6 address to bind to. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
|
||||
/// @param [in] port The port to bind to.
|
||||
/// @note Requires the port given to be forwarded if this is called.
|
||||
void Bind(const Str_8& address, UInt_16 port) override;
|
||||
void Bind(Str_8 address, const UInt_16 &port) override;
|
||||
|
||||
/// Listens for incoming connections. Used for servers or PtP.
|
||||
void Listen() override;
|
||||
@@ -58,7 +58,7 @@ namespace ehs
|
||||
/// Connects to a TCP Socket that listens for incoming connections. Used for clients or PtP.
|
||||
/// @param address The address of the listening TCP socket. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
|
||||
/// @param port The port of the listening TCP socket.
|
||||
void Connect(const Str_8& address, UInt_16 port) override;
|
||||
void Connect(Str_8 address, const UInt_16 &port) override;
|
||||
|
||||
/// Sends data in a C-style array with raw functionality. Meaning no internal help outside of native functions besides error checking.
|
||||
/// @param [in] buffer The C-style array to send.
|
||||
@@ -89,12 +89,12 @@ namespace ehs
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
void Bind_v6(const Str_8& address, UInt_16 port);
|
||||
void Bind_v6(const Str_8 &address, const UInt_16 &port) const;
|
||||
|
||||
void Bind_v4(const Str_8& address, UInt_16 port);
|
||||
void Bind_v4(const Str_8 &address, const UInt_16 &port) const;
|
||||
|
||||
void Connect_v6(const Str_8& address, UInt_16 port);
|
||||
void Connect_v6(const Str_8 &address, const UInt_16 &port);
|
||||
|
||||
void Connect_v4(const Str_8& address, UInt_16 port);
|
||||
void Connect_v4(const Str_8 &address, const UInt_16 &port);
|
||||
};
|
||||
}
|
@@ -46,7 +46,7 @@ namespace ehs
|
||||
/// @param [in] address The local IPv4 or IPv6 address to bind to. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
|
||||
/// @param [in] port The port to bind to.
|
||||
/// @note Requires the port given to be forwarded if this is called.
|
||||
void Bind(const Str_8& address, UInt_16 port) override;
|
||||
void Bind(Str_8 address, const UInt_16 &port) override;
|
||||
|
||||
/// Listens for incoming connections. Used for servers or PtP.
|
||||
void Listen() override;
|
||||
@@ -58,7 +58,7 @@ namespace ehs
|
||||
/// Connects to a TCP Socket that listens for incoming connections. Used for clients or PtP.
|
||||
/// @param address The address of the listening TCP socket. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
|
||||
/// @param port The port of the listening TCP socket.
|
||||
void Connect(const Str_8& address, UInt_16 port) override;
|
||||
void Connect(Str_8 address, const UInt_16 &port) override;
|
||||
|
||||
/// Sends data in a C-style array with raw functionality. Meaning no internal help outside of native functions besides error checking.
|
||||
/// @param [in] buffer The C-style array to send.
|
||||
@@ -89,9 +89,9 @@ namespace ehs
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
void Bind_v6(const Str_8& address, UInt_16 port);
|
||||
void Bind_v6(const Str_8& address, const UInt_16 &port);
|
||||
|
||||
void Bind_v4(const Str_8& address, UInt_16 port);
|
||||
void Bind_v4(const Str_8& address, const UInt_16 &port);
|
||||
|
||||
void Connect_v6(const Str_8& address, UInt_16 port);
|
||||
|
||||
|
Reference in New Issue
Block a user