本文整理汇总了C++中TBreakPacket::UnlinkPart方法的典型用法代码示例。如果您正苦于以下问题:C++ TBreakPacket::UnlinkPart方法的具体用法?C++ TBreakPacket::UnlinkPart怎么用?C++ TBreakPacket::UnlinkPart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBreakPacket
的用法示例。
在下文中一共展示了TBreakPacket::UnlinkPart方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
//--------------------------------------------------------------
void TScLoginClient_MasterImpl::SendResultAccept2ClientAndSlave(unsigned int key,
void* resForClient,
int sizeResClient)
{
// Client
TBreakPacket bp;
bp.PushFront((char*)resForClient, sizeResClient);
THeaderResultLoginM2C hForClient;
hForClient.id_client = key;
hForClient.result = THeaderResultLoginM2C::eAccept;
hForClient.sizeResClient = sizeResClient;
bp.PushFront((char*)&hForClient, sizeof(hForClient));
Context()->GetMS()->Send(GetID_SessionClientMaster(), bp);
bp.UnlinkPart();// очистить от частей
// Slave
THeaderInfoClientM2S hForSlave;
hForSlave.id_client = key;
bp.PushFront((char*)&hForSlave, sizeof(hForSlave));
Context()->GetMS()->Send(GetID_SessionMasterSlave(), bp);
// ждем ответ от Slave
SetWaitSlave();
}
示例2: main
//-------------------------------------------------------------------
int main(int argc, char** argv)
{
#if 0
// внутри MMOEngine
nsMMOEngine::TEventTryLogin erfd;
erfd.id_session = 1;
erfd.sizeData = 100;
TContainer* pC = new TContainer;
pC->SetData(NULL, sizeof(nsMMOEngine::TEventTryLogin) + erfd.sizeData);
memcpy(pC->GetPtr(), &erfd, sizeof(nsMMOEngine::TEventTryLogin));
// внутри DeveloperDLL
nsMMOEngine::TBaseEvent* pBE = (nsMMOEngine::TBaseEvent*)pC->GetPtr();
switch(pBE->mType)
{
case nsMMOEngine::TBase::eTryLogin:
{
nsMMOEngine::TEventTryLogin* pERFD = (nsMMOEngine::TEventTryLogin*)pBE;
break;
}
default:;
}
delete pC;
#endif
g_ShareTest->Init("Client");
TArgData d;
GetByArg(argc,argv,d);
printf("port=%u,TimeSleep=%d,cnt=%d\n",d.port_client, d.time_sleep, d.cnt);
INetTransport* pNetTransport = g_ShareTest->GetTransport();
bool res = pNetTransport->Open(d.port_client);
g_ShareTest->Register();
pNetTransport->Start();
TBreakPacket packetForSend;
if(pNetTransport->Connect(d.ip, TShareTest::ePortServer))
{
unsigned int start = ht_GetMSCount();
for(int i = 0 ; i < TShareTest::eCntRecvPacket ;)
{
for(int j = 0 ; j < d.cnt ; j++ )
{
packetForSend.UnlinkPart();
packetForSend.PushFront(g_ShareTest->GetPacket(), TShareTest::eSizePacket);
pNetTransport->Send(d.ip, TShareTest::ePortServer, packetForSend, true);
i++;
if(i==TShareTest::eCntRecvPacket)
break;
}
ht_msleep(d.time_sleep);
if(g_ShareTest->IsDisconnect())
break;
}
start = ht_GetMSCount() - start;
printf("time=%d ms, v=%f \n",
start,float(TShareTest::eSizePacket*TShareTest::eCntRecvPacket)/(start*1000));
}
pNetTransport->Close(d.ip,TShareTest::ePortServer);
pNetTransport->Stop();
BL_ASSERT(pNetTransport->IsActive()==false);
g_ShareTest->Unregister();
//_getch();
return 0;
}