本文整理汇总了C++中NetConnection::SendReliable方法的典型用法代码示例。如果您正苦于以下问题:C++ NetConnection::SendReliable方法的具体用法?C++ NetConnection::SendReliable怎么用?C++ NetConnection::SendReliable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetConnection
的用法示例。
在下文中一共展示了NetConnection::SendReliable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tmain
//.........这里部分代码省略.........
for (int in = 0; in < i*6; in++)
{
buffer[in] = rand();
}
connection.connection.Send(connection.peers.begin()->second->connection.remoteaddr, buffer, i*6);
delete[] buffer;
}
NetSleep(1000);//wait to receive messages
//get all messages out
//char* out;
while (out = server.Receive(sender, size))
{
delete[] out;
}
printf("Well, we didnt crash, so security test probably didn't fail...\n\n");
connection.connection.SetRTT(0.05);
connection.connection.SetDrop(0.1);
connection.connection.SetVariance(0.02);
//start testing
printf("Testing reliable messages...\n");
int num = 50;
while(num-- > 0)
{
int data[200];
for (int i = 0; i < 200; i++)
{
data[i] = rand();
}
connection.SendReliable((char*)data, sizeof(data));
//ok, now check
Peer* sender; int size;
while (true)
{
char* buffer = server.Receive(sender, size);
if (buffer)
{
if (size == sizeof(data))
{
for (int i = 0; i < 200; i++)
{
assert(((int*)buffer)[i] == data[i]);
}
//printf("one good\n");
}
else
{
printf("Bad message size!!!\n");
}
delete[] buffer;
break;
}
}
}
printf("Reliable message sending passed!\n\n");
printf("Testing reliable ordered messages...\n");
num = 50;
int data[20][200];
for (int i = 0; i < 20; i++)
{