本文整理汇总了C++中tcp_connection::pointer::set_data方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::set_data方法的具体用法?C++ pointer::set_data怎么用?C++ pointer::set_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcp_connection::pointer
的用法示例。
在下文中一共展示了pointer::set_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_from_client
//.........这里部分代码省略.........
case HEADER_CH_CHECKBOT:
FIFOSD_CHECK(sizeof(struct PACKET_CH_CHECKBOT));
{
WFIFOPACKET(cl, spacket, HC_CHECKBOT_RESULT);
spacket->packet_len = sizeof(struct PACKET_HC_CHECKBOT_RESULT);
spacket->result = 1;
cl->send_buffer(spacket->packet_len);
cl->skip(TYPECAST_PACKET_ONCE(RFIFOP(cl,0), CH_CHECKBOT)->packet_len);
}
break;
case HEADER_CH_ENTER:
if(RFIFOREST(cl) < sizeof(struct PACKET_CH_ENTER))
return 0;
{
int account_id = RFIFOL(cl,2);
unsigned int login_id1 = RFIFOL(cl,6);
unsigned int login_id2 = RFIFOL(cl,10);
char sex = RFIFOB(cl,16);
cl->skip(sizeof(struct PACKET_CH_ENTER));
if (csd)
{
break;
}
csd = new CharSessionData();
csd->account_id = account_id;
csd->login_id1 = login_id1;
csd->login_id2 = login_id2;
csd->sex = sex;
csd->auth = false;
csd->cl = cl;
cl->set_data((char*)csd);
WFIFOHEAD(cl, 4);
WFIFOL(cl,0) = account_id;
cl->send_buffer(4);
if (auth_nodes.count(account_id) &&
auth_nodes[account_id].login_id1 == login_id1 &&
auth_nodes[account_id].login_id2 == login_id2)
{
auth_nodes.erase(account_id);
auth_ok(cl, csd);
}
else
{
if (auth_conn_ok)
{
WFIFOHEAD(auth_conn,19);
WFIFOW(auth_conn,0) = INTER_CA_AUTH;
WFIFOL(auth_conn,2) = csd->account_id;
WFIFOL(auth_conn,6) = csd->login_id1;
WFIFOL(auth_conn,10) = csd->login_id2;
WFIFOB(auth_conn,14) = csd->sex;
WFIFOL(auth_conn,15) = cl->tag();
auth_conn->send_buffer(19);
}
else
{
WFIFOPACKET(cl, spacket, HC_REFUSE_ENTER);
spacket->error_code = 0;
cl->send_buffer(sizeof(struct PACKET_HC_REFUSE_ENTER));
}
}