本文整理汇总了C++中raknet::BitStream::ReadCompressed方法的典型用法代码示例。如果您正苦于以下问题:C++ BitStream::ReadCompressed方法的具体用法?C++ BitStream::ReadCompressed怎么用?C++ BitStream::ReadCompressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raknet::BitStream
的用法示例。
在下文中一共展示了BitStream::ReadCompressed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
printf("Demonstration of the RPC4 plugin.\n");
printf("Difficulty: Beginner\n\n");
rakPeer=RakNet::RakPeerInterface::GetInstance();
// Holds user data
char ip[64], serverPort[30], clientPort[30];
// Get our input
puts("Enter the port to listen on");
Gets(clientPort,sizeof(clientPort));
if (clientPort[0]==0)
strcpy(clientPort, "0");
RakNet::SocketDescriptor sd1(atoi(clientPort),0);
rakPeer->Startup(8,&sd1,1);
rakPeer->SetMaximumIncomingConnections(8);
puts("Enter IP to connect to, or enter for none");
Gets(ip, sizeof(ip));
rakPeer->AllowConnectionResponseIPMigration(false);
RPC4 rpc;
rakPeer->AttachPlugin(&rpc);
rpc.RegisterSlot("Event1", CFunc1, 0);
rpc.RegisterSlot("Event1", CFunc2, 0);
rpc.RegisterBlockingFunction("Blocking", CFunc3);
RakNet::Packet *packet;
if (ip[0])
{
puts("Enter the port to connect to");
Gets(serverPort,sizeof(serverPort));
rakPeer->Connect(ip, atoi(serverPort), 0, 0);
RakSleep(1000);
for (packet=rakPeer->Receive(); packet; rakPeer->DeallocatePacket(packet), packet=rakPeer->Receive())
;
RakNet::BitStream testBs;
testBs.WriteCompressed("testData");
// rpc.Signal("Event1", &testBs, HIGH_PRIORITY,RELIABLE_ORDERED,0,rakPeer->GetSystemAddressFromIndex(0),false, true);
RakSleep(100);
for (packet=rakPeer->Receive(); packet; rakPeer->DeallocatePacket(packet), rakPeer->Receive())
;
// Needs 2 program instances, because while the call is blocking rakPeer2->Receive() isn't getting called
RakNet::BitStream testBlockingReturn;
rpc.CallBlocking("Blocking", &testBs, HIGH_PRIORITY,RELIABLE_ORDERED,0,rakPeer->GetSystemAddressFromIndex(0),&testBlockingReturn);
RakNet::RakString data;
bool read = testBlockingReturn.ReadCompressed(data);
printf("%s\n", data.C_String());
}
else
{
printf("Waiting for connections.\n");
while (1)
{
RakSleep(100);
for (packet=rakPeer->Receive(); packet; rakPeer->DeallocatePacket(packet), packet=rakPeer->Receive())
;
}
}
rakPeer->Shutdown(100,0);
RakNet::RakPeerInterface::DestroyInstance(rakPeer);
return 1;
}