本文整理汇总了C++中tcp_connection::pointer类的典型用法代码示例。如果您正苦于以下问题:C++ pointer类的具体用法?C++ pointer怎么用?C++ pointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了pointer类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_accept
void handle_accept(tcp_connection::pointer new_connection, const boost::system::error_code& error)
{
if (!error)
{
new_connection->set_parser(default_parser_);
new_connection->start();
}
start_accept();
}
示例2: handle_accept
void handle_accept(tcp_connection::pointer new_connection, const boost::system::error_code& error)
{
if (!error)
new_connection->start();
start_accept();
}
示例3: handle_accept
void tcp_server::handle_accept(tcp_connection::pointer new_connection, const asio::error_code& error) {
if (!error) {
new_connection->start();
}
start_accept();
}
示例4:
void CharServer::delete2_cancel_ack( tcp_connection::pointer cl, int char_id, int result )
{
WFIFOHEAD(cl,10);
WFIFOW(cl,0) = HEADER_HC_DEL_CANCEL_ACK;
WFIFOL(cl,2) = char_id;
WFIFOL(cl,6) = result;
cl->send_buffer(10);
}
示例5: handler_accept
void handler_accept(tcp_connection::pointer connection, boost::system::error_code& err)
{
if (!err)
{
connection->start();
}
start_accept();
}
示例6: WFIFOW
void CharServer::delete2_ack( tcp_connection::pointer cl, int char_id, int result, time_t deltime )
{
WFIFOHEAD(cl,14);
WFIFOW(cl,0) = HEADER_HC_DEL_REQUEST_ACK;
WFIFOL(cl,2) = char_id;
WFIFOL(cl,6) = result;
WFIFOL(cl,10) = TOL(deltime);
cl->send_buffer(14);
}
示例7: 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);
}
示例8: handle_accept
void tcp_server::handle_accept(tcp_connection::pointer new_connection,
const boost::system::error_code& error) {
std::cout << "handle accept!" << std::endl;
if (!error) {
user_list_[_ID_COUNTER] = new_connection;
new_connection->begin();
}
start_accept();
}
示例9: handle_accept
void handle_accept(tcp_connection::pointer new_connection,
const boost::system::error_code& error)
{
if (!error)
{
new_connection->start();
sLobby.AddPlayer(new_connection);
}
start_accept();
}
示例10: send_chars
/*!
* \brief Send Characters
* \details Send character informations to the client
* \author Fimbulwinter Development Team
* \author GreenBox
* \date 08/12/11
*
**/
void CharServer::send_chars(tcp_connection::pointer cl, CharSessionData *csd)
{
int j = 0;
WFIFOPACKET2(cl, packet, HC_ACCEPT_ENTER, MAX_CHARS * sizeof(CHARACTER_INFO));
#if PACKETVER >= 20100413
packet->total_slots = MAX_CHARS_SLOTS;
packet->premium_slots_start = MAX_CHARS;
packet->premium_slots_end = MAX_CHARS;
#endif
memset(packet->unknown, 0, sizeof(packet->unknown));
packet->packet_len = chars->load_chars_to_buf(csd->account_id, packet->charinfo, csd) * sizeof(CHARACTER_INFO) + sizeof(PACKET_HC_ACCEPT_ENTER);
cl->send_buffer(packet->packet_len);
return;
}
示例11: rcv_handler
void TCPListener::rcv_handler(TCP_Connection::pointer conn, const boost::system::error_code& ec) {
if (!ec) {
conn->start();
}
TCPListener::begin();
}
示例12: begin
void TCPListener::begin() {
TCP_Connection::pointer conn = TCP_Connection::create(io);
listener.async_accept(conn->getSocket(), boost::bind(&TCPListener::rcv_handler, this, conn,
boost::asio::placeholders::err));
}
示例13: parse_from_client
/*!
* \brief Parse from Client
*
* \author Fimbulwinter Development Team
* \author GreenBox
* \date 08/12/11
*
**/
int CharServer::parse_from_client(tcp_connection::pointer cl)
{
CharSessionData *csd = ((CharSessionData *)cl->get_data());
if (cl->flags.eof)
{
if (csd && csd->auth && auth_conn_ok)
{
WFIFOHEAD(auth_conn,6);
WFIFOW(auth_conn,0) = INTER_CA_SET_ACC_OFF;
WFIFOL(auth_conn,2) = csd->account_id;
auth_conn->send_buffer(6);
}
set_char_offline(csd->account_id, -1);
if (csd)
delete csd;
ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", cl->socket().remote_endpoint().address().to_string().c_str());
cl->do_close();
return 0;
}
while(RFIFOREST(cl) >= 2)
{
unsigned short cmd = RFIFOW(cl, 0);
#define FIFOSD_CHECK(rest) { if(RFIFOREST(cl) < rest) return 0; if (csd==NULL || !csd->auth) { cl->skip(rest); return 0; } }
switch (cmd)
{
case HEADER_CH_SELECT_CHAR:
FIFOSD_CHECK(3);
{
int slot = RFIFOB(cl,2);
int char_id;
CharData cd;
cl->skip(3);
{
statement s = (database->prepare << "SELECT `char_id` FROM `char` WHERE `account_id`=:a AND `char_num`=:s",
use(csd->account_id), use(slot), into(char_id));
s.execute(true);
if (s.get_affected_rows() <= 0)
{
WFIFOPACKET(cl, spacket, HC_REFUSE_ENTER);
spacket->error_code = 0;
cl->send_buffer(sizeof(struct PACKET_HC_REFUSE_ENTER));
}
}
chars->load_char(char_id, cd, true);
int server = -1;
if (map_to_zone.count(cd.last_point.map))
server = map_to_zone[cd.last_point.map];
if (server < 0)
{
// TODO: Find for major city
WFIFOPACKET(cl, spacket, SC_NOTIFY_BAN);
spacket->error_code = 1;
cl->send_buffer(sizeof(struct PACKET_SC_NOTIFY_BAN));
break;
}
auth_nodes[csd->account_id].sex = csd->sex;
auth_nodes[csd->account_id].char_id = char_id;
auth_nodes[csd->account_id].gmlevel = csd->gmlevel;
auth_nodes[csd->account_id].login_id1 = csd->login_id1;
auth_nodes[csd->account_id].login_id2 = csd->login_id2;
auth_nodes[csd->account_id].expiration_time = csd->expiration_time;
WFIFOPACKET(cl, spacket, HC_NOTIFY_ZONESVR);
spacket->char_id = char_id;
maps.copy_map_name_ext((char*)spacket->map_name, cd.last_point.map);
spacket->addr.ip = htonl(servers[server].addr.to_ulong());
spacket->addr.port = servers[server].port;
cl->send_buffer(sizeof(struct PACKET_HC_NOTIFY_ZONESVR));
}
break;
case HEADER_CH_REQUEST_DEL_TIMER:
FIFOSD_CHECK(6);
delete2_req(cl, csd);
cl->skip(6);
break;
//.........这里部分代码省略.........
示例14: connect_to_auth
/*!
* \brief Parse from Login
* \details Parse informations from auth server
* \author Fimbulwinter Development Team
* \author GreenBox
* \date 08/12/11
*
**/
int CharServer::parse_from_login(tcp_connection::pointer cl)
{
CharSessionData *csd;
if (cl->flags.eof)
{
cl->do_close();
connect_to_auth();
return 0;
}
while(RFIFOREST(cl) >= 2)
{
unsigned short cmd = RFIFOW(cl, 0);
switch (cmd)
{
case INTER_AC_REQ_ACC_DATA_REPLY:
if (RFIFOREST(cl) < 62)
return 0;
{
int tag = RFIFOL(cl, 2);
if (tcp_connection::session_exists(tag) &&
(csd = (CharSessionData *)tcp_connection::get_session_by_tag(tag)->get_data()))
{
memcpy(csd->email, RFIFOP(cl,6), 40);
csd->expiration_time = (time_t)RFIFOL(cl,46);
csd->gmlevel = RFIFOB(cl,50);
strncpy(csd->birthdate, (const char*)RFIFOP(cl,51), sizeof(csd->birthdate));
// TODO: Check max users and min level to bypass
csd->auth = true;
send_chars(csd->cl, csd);
}
}
cl->skip(62);
break;
case INTER_AC_AUTH_REPLY:
if (RFIFOREST(cl) < 20)
return 0;
{
int account_id = RFIFOL(cl,2);
unsigned int login_id1 = RFIFOL(cl,6);
unsigned int login_id2 = RFIFOL(cl,10);
unsigned char sex = RFIFOB(cl,14);
unsigned char result = RFIFOB(cl,15);
int request_id = RFIFOL(cl,16);
cl->skip(20);
if (tcp_connection::session_exists(request_id) &&
(csd = (CharSessionData *)tcp_connection::get_session_by_tag(request_id)->get_data()) &&
!csd->auth && csd->account_id == account_id && csd->login_id1 == login_id1 &&
csd->login_id2 == login_id2 && csd->sex == sex)
{
tcp_connection::pointer client_cl = csd->cl;
if (result == 0)
{
auth_ok(client_cl, csd);
}
else
{
WFIFOPACKET(client_cl,packet,HC_REFUSE_ENTER);
packet->header = HEADER_HC_REFUSE_ENTER;
packet->error_code = 0;
client_cl->send_buffer(sizeof(struct PACKET_HC_REFUSE_ENTER));
}
}
}
break;
case INTER_AC_KICK:
{
int aid = RFIFOL(cl, 2);
cl->skip(6);
if (online_chars.count(aid))
{
if (online_chars[aid].server > -1)
{
// TODO: Kick from ZoneServer
}
else
{
if (!online_chars[aid].cl->flags.eof)
{
WFIFOPACKET(online_chars[aid].cl,packet,SC_NOTIFY_BAN);
packet->header = HEADER_SC_NOTIFY_BAN;
//.........这里部分代码省略.........