本文整理汇总了C++中tcp_connection::pointer::tag方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::tag方法的具体用法?C++ pointer::tag怎么用?C++ pointer::tag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcp_connection::pointer
的用法示例。
在下文中一共展示了pointer::tag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: auth_ok
/*!
* \brief Connection success into char server
*
* \author Fimbulwinter Development Team
* \author GreenBox
* \date 08/12/11
*
**/
void CharServer::auth_ok(tcp_connection::pointer cl, CharSessionData *csd)
{
if (online_chars.count(csd->account_id))
{
if (online_chars[csd->account_id].server > -1)
{
// TODO: Kick form ZoneServer
if (online_chars[csd->account_id].disconnect_timer)
TimerManager::FreeTimer(online_chars[csd->account_id].disconnect_timer);
set_char_offline(csd->account_id, -1);
WFIFOPACKET(cl, packet, SC_NOTIFY_BAN);
packet->error_code = 8;
cl->send_buffer(sizeof(struct PACKET_SC_NOTIFY_BAN));
return;
}
if (online_chars[csd->account_id].cl->tag() != cl->tag())
{
WFIFOPACKET(cl, packet, SC_NOTIFY_BAN);
packet->error_code = 8;
cl->send_buffer(sizeof(struct PACKET_SC_NOTIFY_BAN));
return;
}
online_chars[csd->account_id].cl = cl;
}
if (auth_conn_ok)
{
WFIFOHEAD(auth_conn,10);
WFIFOW(auth_conn,0) = INTER_CA_REQ_ACC_DATA;
WFIFOL(auth_conn,2) = csd->account_id;
WFIFOL(auth_conn,6) = cl->tag();
auth_conn->send_buffer(10);
}
set_charsel(csd->account_id, cl);
}
示例2: parse_from_client
//.........这里部分代码省略.........
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));
}
}
}
break;
case HEADER_PING:
if (RFIFOREST(cl) < sizeof(PACKET_PING))
return 0;
cl->skip(sizeof(PACKET_PING));
break;
case INTER_ZC_LOGIN:
if (RFIFOREST(cl) < 60)
return 0;
{
char *user = (char*)RFIFOP(cl, 2);
char *pass = (char*)RFIFOP(cl, 26);
if (strcmp(user, config.inter_login_user.c_str()) || strcmp(pass, config.inter_login_pass.c_str()))
{
WFIFOHEAD(cl, 3);
WFIFOW(cl, 0) = INTER_CZ_LOGIN_REPLY;
WFIFOB(cl, 2) = 1;
cl->send_buffer(3);
}
else
{
int id = cl->tag();
servers[id].cl = cl;
servers[id].addr = address_v4(ntohl(RFIFOL(cl, 54)));
servers[id].port = ntohs(RFIFOW(cl, 58));
servers[id].users = 0;
cl->set_parser(&CharServer::parse_from_zone);
cl->flags.server = 1;
cl->realloc_fifo(FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
WFIFOHEAD(cl, 3);
WFIFOW(cl, 0) = INTER_CZ_LOGIN_REPLY;
WFIFOB(cl, 2) = 0;
cl->send_buffer(3);
}
cl->skip(60);
}
break;
default:
ShowWarning("Unknown packet 0x%04x sent from %s, closing connection.\n", cmd, cl->socket().remote_endpoint().address().to_string().c_str());
cl->set_eof();
return 0;
}
}
return 0;
}