递归火山软件开发平台
标题:
C++的回调函数如何转成火山PC定义事件
[打印本页]
作者:
得了吧
时间:
2025-3-21 21:52
标题:
C++的回调函数如何转成火山PC定义事件
// 回调事件
typedef int (*ReceivePacketCallback)(SOCKET socket, const std::vector<uint8_t>& byteData, const std::string& textData);
作者:
Xelloss0618
时间:
2025-3-21 22:37
其实就是在回调函数里调用定义事件,而定义事件需要通过类实例去调用,所以你需要把类实例指针传递给回调函数。
你看看你这个库能不能设置一个用户数据,然后再回调函数里把这个用户数据取出来吧。
作者:
得了吧
时间:
7 天前
Xelloss0618 发表于 2025-3-21 22:37
其实就是在回调函数里调用定义事件,而定义事件需要通过类实例去调用,所以你需要把类实例指针传递给回调函 ...
好的谢谢X大佬
作者:
得了吧
时间:
7 天前
Xelloss0618 发表于 2025-3-21 22:37
其实就是在回调函数里调用定义事件,而定义事件需要通过类实例去调用,所以你需要把类实例指针传递给回调函 ...
X大佬(SOCKET socket, const std::vector<uint8_t>& byteData, const std::string& textData)这种能给个转换列子吗
作者:
得了吧
时间:
7 天前
本帖最后由 得了吧 于 2025-3-22 11:10 编辑
<火山程序 类型 = "通常" 版本 = 1 />
复制代码
作者:
得了吧
时间:
7 天前
<火山程序 类型 = "通常" 版本 = 1 />
# static int ReceivePacketCallback (SOCKET socket, const std::vector<uint8_t>& byteData, const std::string& textData, void* userData)
# {
# return ((@sn<current_class>*)userData)->@<数据进入>( socket, byteData, @an<CVolString> (textData.c_str ()));
# }
<火山程序 类型 = "通常" 版本 = 1 />
方法 数据进入 <公开 定义事件 类型 = 整数>
参数 句柄 <类型 = 变整数>
参数 数据 <类型 = 字节集类>
参数 数据1 <类型 = 文本型>
{
}
复制代码
作者:
Xelloss0618
时间:
7 天前
static int ReceivePacketCallback (SOCKET socket, const std::vector<uint8_t>& byteData, const std::string& textData, void* userData)
{
return ((@sn<current_class>*)userData)->@<数据进入>( socket, @an<CVolMem> (byteData.data(), byteData.size()), @an<CVolString> (textData.c_str ()));
}
欢迎光临 递归火山软件开发平台 (https://bbs.voldp.com/)
Powered by Discuz! X3.4