uWebSockets库ws模板函数参数匹配失败问题求助
uWebSockets库ws模板函数参数匹配失败问题求助
我折腾好几个小时想让uWebSockets库正常跑起来,现在完全摸不着头绪了。当我运行下面这段代码时:
#include <App.h> struct UserData { }; int main() { uWS::App().ws<UserData>("/*", { /* Settings */ .compression = uWS::SHARED_COMPRESSOR, .maxPayloadLength = 16 * 1024, .idleTimeout = 10, /* Handlers */ .upgrade = [](auto *res, auto *req, auto *context) { /* You may read from req only here, and COPY whatever you need into your PerSocketData. * See UpgradeSync and UpgradeAsync examples. */ }, .open = [](auto *ws) { }, .message = [](auto *ws, std::string_view message, uWS::OpCode opCode) { ws->send(message, opCode); }, .drain = [](auto *ws) { /* Check getBufferedAmount here */ }, .ping = [](auto *ws) { }, .pong = [](auto *ws) { }, .close = [](auto *ws, int code, std::string_view message) { } }); }
我遇到了这样的错误:
no instance of function template "uWS::TApp<SSL, false>::ws" matches the argument list
我试着检查了参数类型匹配,也对比了官方示例的写法,但还是没找到问题根源,有没有大佬能帮我排查下哪里出错了?
我自己排查的几个方向(还没解决):
- 确认了
UserData结构体是正确定义的,没有语法问题 - 检查了各个回调函数的参数,看起来和官方示例里的签名一致
- 已经安装了最新版本的uWebSockets库
备注:内容来源于stack exchange,提问作者Haumikj Haumer
相关产品推荐
相关产品推荐

