Hello,
I have a class in which I'm trying to store a pointer to the ws object, but it throws template errors.
Here's the code, the example is from EchoSocket
#include "App.h"
struct PerSocketData {
/* Fill with user data */
};
class Base{
private:
uWS::WebSocket<bool,bool,PerSocketData>* ws;
public:
Base(uWS::WebSocket<bool,bool,PerSocketData>* ws){
this->ws = ws;
}
virtual uWS::WebSocket<bool,bool,PerSocketData>* getws() = 0;
}
int main() {
/* ws->getUserData returns one of these */
/* Keep in mind that uWS::SSLApp({options}) is the same as uWS::App() when compiled without SSL support.
* You may swap to using uWS:App() if you don't need SSL */
uWS::SSLApp({
/* There are example certificates in uWebSockets.js repo */
.key_file_name = "key.pem",
.cert_file_name = "cert.pem",
}).ws<PerSocketData>("/*", {
/* Settings */
.compression = uWS::SHARED_COMPRESSOR,
.maxPayloadLength = 16 * 1024 * 1024,
.idleTimeout = 16,
.maxBackpressure = 1 * 1024 * 1024,
.closeOnBackpressureLimit = false,
.resetIdleTimeoutOnSend = false,
.sendPingsAutomatically = true,
/* Handlers */
.upgrade = nullptr,
.open = [](auto *ws/*ws*/) {
Base b(ws);
},
.message = [](auto* ws, std::string_view message, uWS::OpCode opCode) {
ws->send(message, opCode, true);
},
.drain = [](auto */*ws*/) {
/* Check ws->getBufferedAmount() here */
},
.ping = [](auto */*ws*/, std::string_view) {
/* Not implemented yet */
},
.pong = [](auto */*ws*/, std::string_view) {
/* Not implemented yet */
},
.close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) {
/* You may access ws->getUserData() here */
}
}).listen(443, [](auto *listen_socket) {
if (listen_socket) {
std::cout << "Listening on port " << 443 << std::endl;
}
}).run();
}
Hello, I have a class in which I'm trying to store a pointer to the ws object, but it throws template errors. Here's the code, the example is from EchoSocket
Am I deducing the type of ws wrong?