MQTTSuite
Loading...
Searching...
No Matches
mqtt::mqttbroker::lib Namespace Reference

Classes

class  Mqtt
class  MqttModel

Functions

static std::string windowId (const std::string &clientId)
static std::string href (const std::string &text, const std::string &url, const std::string &windowId, uint16_t width, uint16_t height)

Function Documentation

◆ href()

std::string mqtt::mqttbroker::lib::href ( const std::string & text,
const std::string & url,
const std::string & windowId,
uint16_t width,
uint16_t height )
static

Definition at line 96 of file MqttModel.cpp.

96 {
97 return "<a href=\"#\" onClick=\""
98 "let key = '" +
99 windowId +
100 "'; "
101 "if (!localStorage.getItem(key)) "
102 " localStorage.setItem(key, key + '-' + Math.random().toString(36).substr(2, 6)); "
103 "let uniqueId = localStorage.getItem(key); "
104 "if (!window._openWindows) window._openWindows = {}; "
105 "if (!window._openWindows[uniqueId] || window._openWindows[uniqueId].closed) { "
106 " window._openWindows[uniqueId] = window.open('" +
107 url + "', uniqueId, 'width=" + std::to_string(width) + ", height=" + std::to_string(height) +
108 ",location=no, menubar=no, status=no, toolbar=no'); "
109 "} else { "
110 " window._openWindows[uniqueId].focus(); "
111 "} return false;\" "
112 "style=\"color:inherit;\">" +
113 text + "</a>";
114 }
static std::string windowId(const std::string &clientId)
Definition MqttModel.cpp:82

Referenced by mqtt::mqttbroker::lib::MqttModel::addClient(), and mqtt::mqttbroker::lib::MqttModel::addEventReceiver().

Here is the caller graph for this function:

◆ windowId()

std::string mqtt::mqttbroker::lib::windowId ( const std::string & clientId)
static

Definition at line 82 of file MqttModel.cpp.

82 {
83 std::ostringstream windowId("window");
84 for (char ch : clientId) {
85 if (std::isalnum(static_cast<unsigned char>(ch))) {
86 windowId << ch;
87 } else {
88 windowId << std::hex << std::uppercase << std::setw(2) << std::setfill('0')
89 << static_cast<int>(static_cast<unsigned char>(ch));
90 }
91 }
92
93 return windowId.str();
94 }

Referenced by mqtt::mqttbroker::lib::MqttModel::addClient(), and mqtt::mqttbroker::lib::MqttModel::addEventReceiver().

Here is the caller graph for this function: