本文整理汇总了C++中IPacket类的典型用法代码示例。如果您正苦于以下问题:C++ IPacket类的具体用法?C++ IPacket怎么用?C++ IPacket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IPacket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void BlueVexWrapper::RelayToServer(const unsigned char* bytes, int length, IProxy* proxy, IModule* module)
{
IPacket* packet = proxy->CreatePacket(bytes, length);
packet->SetFlag(IPacket::PacketFlag_Hidden);
proxy->RelayDataToServer(packet,module);
delete packet;
}
示例2: OnRestoreCharacter
int StateLobby::OnRestoreCharacter (IPacket &packet)
{
if (!m_loaded)
return MSG_ERROR_ORDER;
std::string name = packet.Read();
if (!packet.EndOfStream())
return MSG_ERROR_SIZE;
player_iterator i = FindCharacterIndex(name);
if ( i != m_player_list.end() )
{
(*i)->restore();
(*i)->set_timeleft(0);
boost::shared_ptr<OPacket> pkt(new OPacket);
srv_pkt::Lobby(pkt,srv_pkt::LOBBY_ACTION_RESTORE);
m_connection->Send(pkt);
DB::PLAYER::Restore query;
query(m_server->DBConnection(),(*i)->ID());
}
else
return MSG_ERROR_ARG;
return MSG_SUCCESS;
}
示例3: OnTicket
int StateGlobal::OnTicket (const IPacket &packet)
{
Ticket ticket;
ticket.ID = packet.Read<uint32_t>();
ticket.usr = packet.Read();
ticket.pw = packet.Read();
ticket.IP = packet.Read();
ticket.AccountID = packet.Read<uint32_t>();
ticket.access_lv = packet.Read<uint8_t>();
ticket.sec_lv = packet.Read<uint8_t>();
ticket.silk = packet.Read<uint32_t>();
if (!packet.EndOfStream())
return MSG_ERROR_SIZE;
m_service->addTicket(ticket);
return MSG_SUCCESS;
}
示例4: SimpleLog
void IsdnL2::DataReq(QVector<byte> l3data)
{
SimpleLog("DataReq from L3", m_logKinds.general);
IPacket* pPacket = m_pInfra->CreatePacket<IPacket>();
pPacket->Fill(l3data);
//m_l2obj.DatReq( pPacket->Clone() );
m_l2obj.DatReq( pPacket );
}
示例5: decode
/**将缓冲区的数据 解码为请求,并且放置请求队列
*/
void Connection::decode(){
IPacket *p = NULL;
_readlock.lock();
while( (p = _streamer->decodeToPacket(_readbuf) ) !=NULL ){
p->setConnection( const_cast<const Connection*>(this) );
Transport::instance().getWritePacketQueue()->push(p);
}
_readlock.unlock();
}
示例6: OnGMCommand_AllowLogout
int StateGame::OnGMCommand_AllowLogout (IPacket &packet)
{
std::string playerName = packet.Read();
if (!packet.EndOfStream())
return MSG_ERROR_SIZE;
return MSG_SUCCESS;
}
示例7: OnGMCommand_RecallGuild
int StateGame::OnGMCommand_RecallGuild (IPacket &packet)
{
std::string guildName = packet.Read();
if (!packet.EndOfStream())
return MSG_ERROR_SIZE;
return MSG_SUCCESS;
}
示例8: OnGMCommand_LieName
int StateGame::OnGMCommand_LieName (IPacket &packet)
{
std::string name = packet.Read();
if (!packet.EndOfStream())
return MSG_ERROR_SIZE;
return MSG_SUCCESS;
}
示例9: PrintPacketToSyslog
void PrintPacketToSyslog (const IPacket &packet)
{
std::stringstream ss;
const char *buffer = (const char*)packet.buffer();
for (int i = 0; i < packet.size(); ++i)
ss << std::hex << std::setw(2) << std::setfill('0') << ((int)buffer[i] & 0xFF) << " ";
syslog(LOG_DEBUG,"Hexed Packet:\n%s",ss.str().c_str());
}
示例10: sendPacket
bool Server::sendPacket (IPacket& packet) {
buffer_t b;
packet.toBuffer (b);
THeader h;
h.type = packet.getType ();
h.size = b.size ();
THeader* tHPtr = &h;
send (ConnectSocket, reinterpret_cast<char*>(tHPtr), sizeof (h), 0);
send (ConnectSocket, &b[0], b.size(), 0);
return true;
}
示例11: return
IPacket *PacketBuilder::build(char *data, int clientId)
{
int opcode = *(int *)(data + 4);
if (builder_.find(opcode) != builder_.end())
{
IPacket *packet;
if ((packet = (this->*builder_[opcode])(opcode, data + HEADER_SIZE)) == nullptr)
return (nullptr);
packet->setClientId(clientId);
return (packet);
}
return (nullptr);
}
示例12: OnWhoIs
int IStateHandshake::OnWhoIs (const IPacket &packet)
{
std::string srvID = packet.Read();
uint8_t resv = packet.Read<uint8_t>();
if (!packet.EndOfStream())
return MSG_ERROR_SIZE;
if (resv || srvID != m_SrvID)
return MSG_ERROR_ARG;
OnConfig();
return MSG_SUCCESS;
}
示例13: OnValidateCharacterName
int StateLobby::OnValidateCharacterName (IPacket &packet)
{
std::string name = packet.Read();
if (!packet.EndOfStream())
return MSG_ERROR_SIZE;
if (IsNameValid(name))
{
boost::shared_ptr<OPacket> pkt(new OPacket);
srv_pkt::Lobby(pkt,srv_pkt::LOBBY_ACTION_VALIDATE_NAME);
m_connection->Send(pkt);
}
return MSG_SUCCESS;
}
示例14: OnStatsStrInc
int StateGame::OnStatsStrInc (IPacket &packet)
{
if (!packet.EndOfStream())
return MSG_ERROR_SIZE;
boost::shared_ptr<Player> player = static_cast<srv::Connection*>(m_connection)->GetPlayer();
if (!player)
return MSG_ERROR;
if (player->get_stat())
{
player->inc_str();
DB::PLAYER::Stats query;
query(m_server->DBConnection(),player);
boost::shared_ptr<OPacket> pkt(new OPacket);
srv_pkt::IncStr(pkt);
m_connection->Send(pkt);
boost::shared_ptr<Party> party = player->get_party();
if (party)
{
party->SendHPMPNotification(player->GetUniqueID(),player->hp(),player->max_hp(),player->mp(),
player->max_mp());
}
}
return MSG_SUCCESS;
}
示例15: OnGMCommand_SpawnAllUniques
int StateGame::OnGMCommand_SpawnAllUniques (IPacket &packet)
{
if (!packet.EndOfStream())
return MSG_ERROR_SIZE;
return MSG_SUCCESS;
}