SNode.C
Loading...
Searching...
No Matches
web::http::legacy::rc Namespace Reference

Classes

class  EventSource
 

Typedefs

using Client = web::http::client::Client< net::rc::stream::legacy::SocketClient >
 
using Server = web::http::server::Server< net::rc::stream::legacy::SocketServer >
 

Functions

std::shared_ptr< web::http::client::tools::EventSourceEventSource (const std::string &scheme, const net::rc::SocketAddress &socketAddress, const std::string &path)
 
std::shared_ptr< web::http::client::tools::EventSourceEventSource (const std::string &host, uint8_t channel, const std::string &path)
 
std::shared_ptr< web::http::client::tools::EventSourceEventSource (const std::string &url)
 
std::shared_ptr< web::http::client::tools::EventSourceEventSource (std::string origin, std::string path)
 

Typedef Documentation

◆ Client

◆ Server

Function Documentation

◆ EventSource() [1/4]

std::shared_ptr< web::http::client::tools::EventSource > web::http::legacy::rc::EventSource ( const std::string &  host,
uint8_t  channel,
const std::string &  path 
)
inline

Definition at line 80 of file EventSource.h.

References EventSource(), and net::rc::SocketAddress::SocketAddress().

Here is the call graph for this function:

◆ EventSource() [2/4]

std::shared_ptr< web::http::client::tools::EventSource > web::http::legacy::rc::EventSource ( const std::string &  scheme,
const net::rc::SocketAddress socketAddress,
const std::string &  path 
)
inline

Definition at line 72 of file EventSource.h.

72 {
73 std::shared_ptr<class EventSource> eventSource = std::make_shared<class EventSource>();
74 eventSource->init(scheme, socketAddress, path);
75
76 return eventSource;
77 }

Referenced by EventSource().

Here is the caller graph for this function:

◆ EventSource() [3/4]

std::shared_ptr< web::http::client::tools::EventSource > web::http::legacy::rc::EventSource ( const std::string &  url)
inline

Definition at line 85 of file EventSource.h.

85 {
86 std::shared_ptr<web::http::client::tools::EventSource> eventSource;
87
88 static const std::regex re(
89 R"(^(?:rfcomm://)(?![^/]*@)((?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}|[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*)"
90 R"(?::([1-9]|[12]\d|30))?([^?#]*)(\?[^#]*)?(?:#.*)?$)",
91 std::regex::ECMAScript | std::regex::icase);
92
93 std::smatch match;
94 if (std::regex_match(url, match, re)) {
95 // rfcomm://<mac-or-host>[:<channel>][/path][?query][#fragment]
96 // [1] addr -> MAC "01:23:45:67:89:AB" OR hostname
97 // [2] chan -> RFCOMM channel 1..30 (optional; default 1)
98 // [3] path -> may be empty; default "/"
99 // [4] query -> optional
100
101 const std::string scheme = "rfcomm"; // fixed
102 const std::string addr = match[1].str(); // MAC or hostname
103 const uint8_t chan = match[2].matched ? static_cast<uint8_t>(std::stoi(match[2].str())) : static_cast<uint16_t>(1);
104 const std::string path = match[3].matched ? match[3].str() : "/";
105 const std::string query = match[4].matched ? match[4].str() : "";
106
107 eventSource = std::make_shared<class EventSource>(scheme, net::rc::SocketAddress(addr, chan), path + query);
108 } else {
109 LOG(ERROR) << "EventSource RFCOMM url not accepted: " << url;
110 }
111
112 return eventSource;
113 }

References net::rc::SocketAddress::SocketAddress().

Here is the call graph for this function:

◆ EventSource() [4/4]

std::shared_ptr< web::http::client::tools::EventSource > web::http::legacy::rc::EventSource ( std::string  origin,
std::string  path 
)
inline

Definition at line 115 of file EventSource.h.

115 {
116 if (!origin.empty() && origin.at(origin.length() - 1) == '/') {
117 origin.pop_back();
118 }
119
120 if (!path.empty() && path.at(0) != '/') {
121 path = "/" + path;
122 }
123
124 return EventSource(!origin.empty() ? origin + path : "");
125 }