std::vector<ConstBuffer> Reply::ToBuffers() { std::vector<ConstBuffer> buffers; buffers.push_back(StatusText::ToBuffer(status)); for (std::size_t i = 0; i < headers.size(); ++i) { Header& h = headers[i]; buffers.push_back(h.name); buffers.push_back(StatusText::Separator); buffers.push_back(h.value); buffers.push_back(StatusText::CrLf); } buffers.push_back(StatusText::CrLf); if (content.data) buffers.push_back(ConstBuffer(content.data.get(), content.size)); return buffers; }
VBool VNetworkProcessPacketManager::OnReceive( SessionPtr pSession,vchat::VChatUserPtr pPlayer, const ChatHeader* pHeader, const VMutableBuffer & buff, const VBool &bOwnMem) { if (pPlayer ) { if( pPlayer->CheckSecurity(pHeader->crc, pHeader->seq, buff.second, buff.first) == VFalse) { if( buff.second && !bOwnMem) VAllocateManager::Instance().DeAllocate(buff.second, (VInt32)buff.first); return VFalse; } if (pHeader->type > vchat::Packet::c2s_gs_unknown && pHeader->type < vchat::Packet::c2s_gs_count) { vchat::VChatProcessPacketManager::Instance().ProcessPacket(pPlayer, pHeader, ConstBuffer(buff.first, buff.second)); if( buff.second && !bOwnMem) VAllocateManager::Instance().DeAllocate(buff.second, (VInt32)buff.first); } else if (pHeader->type > vchat::Packet::c2s_db_unknown && pHeader->type < vchat::Packet::c2s_db_count) { VDatabaseManager::Instance().ProcessPacket(pPlayer,pHeader->type, buff.second, buff.first); } else if(pHeader->type > vchat::Packet::c2s_guild_unknow && pHeader->type < vchat::Packet::c2s_guild_count) { VGuildProcessPacket::Instance().ProcessPacket(pPlayer,pHeader->type, buff.second, buff.first, !bOwnMem); } } else { if (pHeader->type == vchat::Packet::c2s_db_login) { VDatabaseManager::Instance().ProcessLogin(pSession, buff.second, buff.first); if( buff.second && !bOwnMem) VAllocateManager::Instance().DeAllocate(buff.second, (VInt32)buff.first); } } return VTrue; }