C语言问题
Closed this issue · 6 comments
baidwwy commented
callback函数如何知道自己的数据?
HP_Set_FN_Server_xxxx的函数是否应该添加一个userdata
或者类似 HP_Server_SetConnectionExtra 弄个setuserdata
HP_Server_SetConnectionExtra只能对连接设置
ldcsaa commented
回调函数第一个参数,pSender
baidwwy commented
我是说自定义数据,类似 HP_Server_SetConnectionExtra
ldcsaa commented
pSender就是组件的this指针了,有了this不就能看对象的信息了么?
FunlyDay commented
这是来自樊 邮箱的自动回复邮件。 您好,您发的邮件我已收到,我会及时查看并予以回复。
baidwwy commented
C语言啊,pSender指向HP_Object,就一指针有什么用啊,自己写索引吗
baidwwy commented
static void on_recv(hio_t *io, void *buf, int len)
{
connection_t *conn = (connection_t *)hevent_userdata(io);
if (!conn)
return;
lua_State *L = conn->svr->L;
if (conn->svr->lon_recv)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, conn->svr->lon_recv);
lua_pushinteger(L, hio_id(io));
lua_pushlstring(L, (char *)buf, len);
lua_call(L, 2, 0);
}
}
这是一个简单的userdata