本文整理汇总了C++中datastructures::List类的典型用法代码示例。如果您正苦于以下问题:C++ List类的具体用法?C++ List怎么用?C++ List使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了List类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: OnConnectionRequestAccepted
PluginReceiveResult NatPunchthrough::OnConnectionRequestAccepted(Packet *packet)
{
unsigned i;
i=0;
while (i < connectionRequestList.Size())
{
DataStructures::List<SystemAddress> fallbackAddresses;
connectionRequestList[i]->GetAddressList(rakPeer, fallbackAddresses, connectionRequestList[i]->receiverPublic, connectionRequestList[i]->receiverPrivate, false);
if (fallbackAddresses.GetIndexOf(packet->systemAddress)!=(unsigned) -1)
{
rakFree(connectionRequestList[i]->passwordData);
delete connectionRequestList[i];
connectionRequestList.RemoveAtIndex(i);
return RR_CONTINUE_PROCESSING;
}
i++;
}
// return to user
return RR_CONTINUE_PROCESSING;
}
开发者ID:bazhenovc,项目名称:nebula3,代码行数:23,代码来源:NatPunchthrough.cpp
示例2: Get
bool CloudClient::Get(CloudQuery *keyQuery, DataStructures::List<CloudQueryRow*> &specificSystems, RakNetGUID systemIdentifier)
{
RakNet::BitStream bsOut;
bsOut.Write((MessageID)ID_CLOUD_GET_REQUEST);
keyQuery->Serialize(true, &bsOut);
bsOut.WriteCasted<uint16_t>(specificSystems.Size());
RakAssert(specificSystems.Size() < (uint16_t)-1 );
for (uint16_t i=0; i < specificSystems.Size(); i++)
{
if (specificSystems[i]->clientGUID!=UNASSIGNED_RAKNET_GUID)
{
bsOut.Write(true);
bsOut.Write(specificSystems[i]->clientGUID);
}
else
{
bsOut.Write(false);
bsOut.Write(specificSystems[i]->clientSystemAddress);
}
}
SendUnified(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, systemIdentifier, false);
return true;
}
开发者ID:Abagail,项目名称:SA-MP-Plus,代码行数:23,代码来源:CloudClient.cpp
示例3:
void PHPDirectoryServer2::PushColumnsAndValues(DataStructures::List<RakNet::RakString> &columns, DataStructures::List<RakNet::RakString> &values)
{
DataStructures::Table::Row *row=0;
unsigned int i;
for (i=0; i < columns.Size() && i < values.Size(); i++)
{
if (columns[i].IsEmpty()==false)
{
unsigned col = lastDownloadedTable.ColumnIndex(columns[i]);
if(col == (unsigned)-1)
{
col = lastDownloadedTable.AddColumn(columns[i], DataStructures::Table::STRING);
}
if (row==0)
{
row = lastDownloadedTable.AddRow(lastDownloadedTable.GetAvailableRowId());
}
row->UpdateCell(col,values[i].C_String());
}
}
}
开发者ID:0521guo,项目名称:RakNet,代码行数:23,代码来源:PHPDirectoryServer2.cpp
示例4: SerializeRow
void TableSerializer::SerializeRow(DataStructures::Table::Row *in, unsigned keyIn, DataStructures::List<DataStructures::Table::ColumnDescriptor> &columns, RakNet::BitStream *out, DataStructures::List<int> &skipColumnIndices)
{
unsigned cellIndex;
out->Write(keyIn);
unsigned int numEntries=0;
for (cellIndex=0; cellIndex<columns.Size(); cellIndex++)
{
if (skipColumnIndices.GetIndexOf(cellIndex)==(unsigned)-1)
{
numEntries++;
}
}
out->Write(numEntries);
for (cellIndex=0; cellIndex<columns.Size(); cellIndex++)
{
if (skipColumnIndices.GetIndexOf(cellIndex)==(unsigned)-1)
{
out->Write(cellIndex);
SerializeCell(out, in->cells[cellIndex], columns[cellIndex].columnType);
}
}
}
开发者ID:venkatarajasekhar,项目名称:viper,代码行数:23,代码来源:TableSerializer.cpp
示例5: GetCommandListReplicaIndex
unsigned ReplicaManager::GetCommandListReplicaIndex(const DataStructures::List<ReplicaManager::CommandStruct> &commandList, Replica *replica, bool *objectExists) const
{
unsigned i;
for (i=0; i < commandList.Size(); i++)
{
if (commandList[i].replica==replica)
{
*objectExists=true;
return i;
}
}
*objectExists=false;
return 0;
}
开发者ID:pulkomandy,项目名称:.theRush-,代码行数:14,代码来源:ReplicaManager.cpp
示例6:
void FullyConnectedMesh2::GetHostOrder(DataStructures::List<RakNetGUID> &hostList)
{
hostList.Clear(true, _FILE_AND_LINE_);
if (ourFCMGuid==0 || fcm2ParticipantList.Size()==0)
{
hostList.Push(rakPeerInterface->GetMyGUID(), _FILE_AND_LINE_);
return;
}
FCM2Participant fcm2;
fcm2.fcm2Guid=ourFCMGuid;
fcm2.rakNetGuid=rakPeerInterface->GetMyGUID();
DataStructures::OrderedList<FCM2Participant, FCM2Participant, FCM2ParticipantComp> olist;
olist.Insert(fcm2, fcm2, true, _FILE_AND_LINE_);
for (unsigned int i=0; i < fcm2ParticipantList.Size(); i++)
olist.Insert(fcm2ParticipantList[i], fcm2ParticipantList[i], true, _FILE_AND_LINE_);
for (unsigned int i=0; i < olist.Size(); i++)
{
hostList.Push(olist[i].rakNetGuid, _FILE_AND_LINE_);
}
}
开发者ID:Arkamarante,项目名称:collision-domain,代码行数:24,代码来源:FullyConnectedMesh2.cpp
示例7: enter
void ServerState::enter()
{
// console setup
GG.console->clear();
GG.gui.attach(GG.console);
// raknet
mServer = RakNetworkFactory::GetRakPeerInterface();
mServer->SetIncomingPassword("Rumpelstiltskin", (int)strlen("Rumpelstiltskin"));
mSocketDesc = SocketDescriptorPtr(new SocketDescriptor(SERVER_PORT, 0));
bool b = mServer->Startup(4, 30, mSocketDesc.get(), 1);
mServer->SetMaximumIncomingConnections(4);
mServer->SetOccasionalPing(true);
mServer->SetUnreliableTimeout(1000);
GuiConsoleOutput cout = GG.console->output();
cout << "Wargame server" << endl;
cout << "local IP: " << mServer->GetLocalIP(0) << endl;
cout << "GUID: " << mServer->GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS).ToString() << endl;
DataStructures::List<RakNetSmartPtr<RakNetSocket> > sockets;
mServer->GetSockets(sockets);
cout << "Ports used by RakNet:\n";
for (unsigned int i=0; i < sockets.Size(); i++) {
cout << i+1 << " " << sockets[i]->boundAddress.port << endl;
}
cout.flush();
// console callback invoked on text input
GG.console->slot("textInput", GuiCallbackPtr(new ServerConsoleInput(GG, *this)));
// network classes
mGameClient = WargameClientPtr(new WargameClient());
mGameServer = WargameServerPtr(new WargameServer());
}
开发者ID:safetydank,项目名称:Hexpad,代码行数:36,代码来源:ServerState.cpp
示例8: DeleteFilterSet
void MessageFilter::DeleteFilterSet(int filterSetID)
{
FilterSet *filterSet;
bool objectExists;
unsigned i,index;
index = filterList.GetIndexFromKey(filterSetID, &objectExists);
if (objectExists)
{
filterSet=filterList[index];
DeallocateFilterSet(filterSet);
filterList.RemoveAtIndex(index);
DataStructures::List< FilteredSystem > itemList;
DataStructures::List< AddressOrGUID > keyList;
systemList.GetAsList(itemList, keyList, _FILE_AND_LINE_);
for (i=0; i < itemList.Size(); i++)
{
if (itemList[i].filter==filterSet)
{
systemList.Remove(keyList[i], _FILE_AND_LINE_);
}
}
/*
// Don't reference this pointer any longer
i=0;
while (i < systemList.Size())
{
if (systemList[i].filter==filterSet)
systemList.RemoveAtIndex(i);
else
++i;
}
*/
}
}
开发者ID:DiGiCT,项目名称:RN4UE4,代码行数:36,代码来源:MessageFilter.cpp
示例9: OpenNATGroup
bool NatPunchthroughClient::OpenNATGroup(DataStructures::List<RakNetGUID> destinationSystems, const SystemAddress &facilitator)
{
ConnectionState cs = rakPeerInterface->GetConnectionState(facilitator);
if (cs!=IS_CONNECTED)
return false;
unsigned long i;
for (i=0; i < destinationSystems.Size(); i++)
{
SendPunchthrough(destinationSystems[i], facilitator);
}
GroupPunchRequest *gpr = RakNet::OP_NEW<GroupPunchRequest>(_FILE_AND_LINE_);
gpr->facilitator=facilitator;
gpr->pendingList=destinationSystems;
groupPunchRequests.Push(gpr, _FILE_AND_LINE_);
return true;
}
开发者ID:SuperMagicBadger,项目名称:Zombiess,代码行数:19,代码来源:NatPunchthroughClient.cpp
示例10:
PluginReceiveResult FullyConnectedMesh2::OnVerifiedJoinCapable(Packet *packet)
{
VerifiedJoinInProgress vjip;
DecomposeJoinCapable(packet, &vjip);
// If this assert hits, AddParticipant() was called on this system, or another system, which it should not have been.
RakAssert(HasParticipant(packet->guid)==false);
DataStructures::List<RakNetGUID> participatingMembersOnClientSucceeded;
DataStructures::List<RakNetGUID> participatingMembersOnClientFailed;
DataStructures::List<RakNetGUID> participatingMembersNotOnClient;
DataStructures::List<RakNetGUID> clientMembersNotParticipatingSucceeded;
DataStructures::List<RakNetGUID> clientMembersNotParticipatingFailed;
CategorizeVJIP(&vjip,
participatingMembersOnClientSucceeded,
participatingMembersOnClientFailed,
participatingMembersNotOnClient,
clientMembersNotParticipatingSucceeded,
clientMembersNotParticipatingFailed);
if (participatingMembersOnClientFailed.Size()>0)
{
// Send ID_FCM2_VERIFIED_JOIN_FAILED with GUIDs to disconnect
BitStream bsOut;
bsOut.Write((MessageID) ID_FCM2_VERIFIED_JOIN_FAILED);
SendUnified(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, packet->guid, false);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
}
if (participatingMembersNotOnClient.Size()>0)
{
BitStream bsOut;
bsOut.Write((MessageID) ID_FCM2_VERIFIED_JOIN_START);
bsOut.WriteCasted<unsigned short>(participatingMembersNotOnClient.Size());
unsigned int i;
for (i=0; i < participatingMembersNotOnClient.Size(); i++)
{
bsOut.Write(participatingMembersNotOnClient[i]);
bsOut.Write(rakPeerInterface->GetSystemAddressFromGuid(participatingMembersNotOnClient[i]));
}
SendUnified(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, packet->guid, false);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
}
// Let server decide if to accept or reject via RespondOnVerifiedJoinCapable
return RR_CONTINUE_PROCESSING;
}
开发者ID:xboxxxxd,项目名称:sc4multi,代码行数:47,代码来源:FullyConnectedMesh2.cpp
示例11: Unsubscribe
void CloudClient::Unsubscribe(DataStructures::List<CloudKey> &keys, DataStructures::List<RakNetGUID> &specificSystems, RakNetGUID systemIdentifier)
{
SLNet::BitStream bsOut;
bsOut.Write((MessageID)ID_CLOUD_UNSUBSCRIBE_REQUEST);
RakAssert(keys.Size() < (uint16_t)-1 );
bsOut.WriteCasted<uint16_t>(keys.Size());
for (uint16_t i=0; i < keys.Size(); i++)
{
keys[i].Serialize(true,&bsOut);
}
bsOut.WriteCasted<uint16_t>(specificSystems.Size());
RakAssert(specificSystems.Size() < (uint16_t)-1 );
for (uint16_t i=0; i < specificSystems.Size(); i++)
{
bsOut.Write(specificSystems[i]);
}
SendUnified(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, systemIdentifier, false);
}
开发者ID:TrevorCash,项目名称:Urho3D,代码行数:18,代码来源:CloudClient.cpp
示例12: RunTest
/*
What is being done here is having 8 peers all connect to eachother over the max defined connection.
It runs the connect, wait 20 seconds then see the current connections.
Success conditions:
All extra connections Refused.
Failure conditions:
There are more connected than allowed.
The connect function fails, the test is not even done.
GetMaximumIncomingConnections returns wrong value.
RakPeerInterface Functions used, tested indirectly by its use:
Startup
Connect
SetMaximumIncomingConnections
Receive
DeallocatePacket
GetSystemList
RakPeerInterface Functions Explicitly Tested:
SetMaximumIncomingConnections
GetMaximumIncomingConnections
*/
int MaximumConnectTest::RunTest(DataStructures::List<RakString> params,bool isVerbose,bool noPauses)
{
const int peerNum= 8;
const int maxConnections=4;//Max allowed connections for test
RakPeerInterface *peerList[peerNum];//A list of 8 peers
Packet *packet;
destroyList.Clear(false,_FILE_AND_LINE_);
int connReturn;
//Initializations of the arrays
for (int i=0;i<peerNum;i++)
{
peerList[i]=RakPeerInterface::GetInstance();
destroyList.Push(peerList[i],_FILE_AND_LINE_);
peerList[i]->Startup(maxConnections, &SocketDescriptor(60000+i,0), 1);
peerList[i]->SetMaximumIncomingConnections(maxConnections);
connReturn=peerList[i]->GetMaximumIncomingConnections();
if (connReturn!=maxConnections)
{
if (isVerbose)
{
printf("Getmaxconnections wrong for peer %i, %i should be the value but the value is %i.Fail\n",i,maxConnections,connReturn);
DebugTools::ShowError("",!noPauses && isVerbose,__LINE__,__FILE__);
}
}
}
//Connect all the peers together
for (int i=0;i<peerNum;i++)
{
for (int j=i+1;j<peerNum;j++)//Start at i+1 so don't connect two of the same together.
{
if (peerList[i]->Connect("127.0.0.1", 60000+j, 0,0)!=CONNECTION_ATTEMPT_STARTED)
{
if (isVerbose)
DebugTools::ShowError("Problem while calling connect.\n",!noPauses && isVerbose,__LINE__,__FILE__);
return 1;//This fails the test, don't bother going on.
}
}
}
TimeMS entryTime=GetTimeMS();//Loop entry time
while(GetTimeMS()-entryTime<20000)//Run for 20 Secoonds
{
for (int i=0;i<peerNum;i++)//Receive for all peers
{
packet=peerList[i]->Receive();
if (isVerbose&&packet)
printf("For peer %i\n",i);
while(packet)
{
switch (packet->data[0])
{
//.........这里部分代码省略.........
开发者ID:Darrenbydesign,项目名称:HoloToolkit,代码行数:101,代码来源:MaximumConnectTest.cpp
示例13: main
_CONSOLE_2_SetSystemProcessParams
#endif
int main(void)
{
// Pointers to the interfaces of our server and client.
// Note we can easily have both in the same program
RakPeerInterface *server=RakNetworkFactory::GetRakPeerInterface();
RakNetStatistics *rss;
server->SetIncomingPassword("Rumpelstiltskin", (int)strlen("Rumpelstiltskin"));
server->SetTimeoutTime(30000,UNASSIGNED_SYSTEM_ADDRESS);
// PacketLogger packetLogger;
// server->AttachPlugin(&packetLogger);
// Holds packets
Packet* p;
// GetPacketIdentifier returns this
unsigned char packetIdentifier;
// Record the first client that connects to us so we can pass it to the ping function
SystemAddress clientID=UNASSIGNED_SYSTEM_ADDRESS;
// Holds user data
char portstring[30];
printf("This is a sample implementation of a text based chat server.\n");
printf("Connect to the project 'Chat Example Client'.\n");
printf("Difficulty: Beginner\n\n");
// A server
puts("Enter the server port to listen on");
gets(portstring);
if (portstring[0]==0)
strcpy(portstring, "1234");
puts("Starting server.");
// Starting the server is very simple. 2 players allowed.
// 0 means we don't care about a connectionValidationInteger, and false
// for low priority threads
SocketDescriptor socketDescriptor(atoi(portstring),0);
bool b = server->Startup(4, 30, &socketDescriptor, 1 );
server->SetMaximumIncomingConnections(4);
if (b)
puts("Server started, waiting for connections.");
else
{
puts("Server failed to start. Terminating.");
exit(1);
}
server->SetOccasionalPing(true);
server->SetUnreliableTimeout(1000);
DataStructures::List<RakNetSmartPtr<RakNetSocket> > sockets;
server->GetSockets(sockets);
printf("Ports used by RakNet:\n");
for (unsigned int i=0; i < sockets.Size(); i++)
{
printf("%i. %i\n", i+1, sockets[i]->boundAddress.port);
}
printf("My IP is %s\n", server->GetLocalIP(0));
printf("My GUID is %s\n", server->GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS).ToString());
puts("'quit' to quit. 'stat' to show stats. 'ping' to ping.\n'ban' to ban an IP from connecting.\n'kick to kick the first connected player.\nType to talk.");
char message[2048];
// Loop for input
while (1)
{
// This sleep keeps RakNet responsive
RakSleep(30);
#ifdef _WIN32
if (kbhit())
{
// Notice what is not here: something to keep our network running. It's
// fine to block on gets or anything we want
// Because the network engine was painstakingly written using threads.
gets(message);
if (strcmp(message, "quit")==0)
{
puts("Quitting.");
break;
}
if (strcmp(message, "stat")==0)
{
rss=server->GetStatistics(server->GetSystemAddressFromIndex(0));
StatisticsToString(rss, message, 2);
printf("%s", message);
printf("Ping %i\n", server->GetAveragePing(server->GetSystemAddressFromIndex(0)));
continue;
}
if (strcmp(message, "ping")==0)
{
server->Ping(clientID);
//.........这里部分代码省略.........
开发者ID:coolblaze03,项目名称:ts3lol,代码行数:101,代码来源:Chat+Example+Server.cpp
示例14: QueryRow
void Table::QueryRow(DataStructures::List<unsigned> &inclusionFilterColumnIndices, DataStructures::List<unsigned> &columnIndicesToReturn, unsigned key, Table::Row* row, FilterQuery *inclusionFilters, Table *result)
{
bool pass=false;
unsigned columnIndex;
unsigned j;
// If no inclusion filters, just add the row
if (inclusionFilterColumnIndices.Size()==0)
{
result->AddRowColumns(key, row, columnIndicesToReturn);
}
else
{
// Go through all inclusion filters. Only add this row if all filters pass.
for (j=0; j<inclusionFilterColumnIndices.Size(); j++)
{
columnIndex=inclusionFilterColumnIndices[j];
if (columnIndex!=(unsigned)-1 && row->cells[columnIndex]->isEmpty==false )
{
if (columns[inclusionFilterColumnIndices[j]].columnType==STRING &&
row->cells[columnIndex]->c==0 ||
inclusionFilters[j].cellValue->c==0 )
continue;
switch (inclusionFilters[j].operation)
{
case QF_EQUAL:
switch(columns[inclusionFilterColumnIndices[j]].columnType)
{
case NUMERIC:
pass=row->cells[columnIndex]->i==inclusionFilters[j].cellValue->i;
break;
case STRING:
pass=strcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c)==0;
break;
case BINARY:
pass=row->cells[columnIndex]->i==inclusionFilters[j].cellValue->i &&
memcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c, row->cells[columnIndex]->i)==0;
break;
case POINTER:
pass=row->cells[columnIndex]->ptr==inclusionFilters[j].cellValue->ptr;
break;
}
break;
case QF_NOT_EQUAL:
switch(columns[inclusionFilterColumnIndices[j]].columnType)
{
case NUMERIC:
pass=row->cells[columnIndex]->i!=inclusionFilters[j].cellValue->i;
break;
case STRING:
pass=strcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c)!=0;
break;
case BINARY:
pass=row->cells[columnIndex]->i==inclusionFilters[j].cellValue->i &&
memcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c, row->cells[columnIndex]->i)==0;
break;
case POINTER:
pass=row->cells[columnIndex]->ptr!=inclusionFilters[j].cellValue->ptr;
break;
}
break;
case QF_GREATER_THAN:
switch(columns[inclusionFilterColumnIndices[j]].columnType)
{
case NUMERIC:
pass=row->cells[columnIndex]->i>inclusionFilters[j].cellValue->i;
break;
case STRING:
pass=strcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c)>0;
break;
case BINARY:
break;
case POINTER:
pass=row->cells[columnIndex]->ptr>inclusionFilters[j].cellValue->ptr;
break;
}
break;
case QF_GREATER_THAN_EQ:
switch(columns[inclusionFilterColumnIndices[j]].columnType)
{
case NUMERIC:
pass=row->cells[columnIndex]->i>=inclusionFilters[j].cellValue->i;
break;
case STRING:
pass=strcmp(row->cells[columnIndex]->c,inclusionFilters[j].cellValue->c)>=0;
break;
case BINARY:
break;
case POINTER:
pass=row->cells[columnIndex]->ptr>=inclusionFilters[j].cellValue->ptr;
break;
}
break;
case QF_LESS_THAN:
switch(columns[inclusionFilterColumnIndices[j]].columnType)
{
case NUMERIC:
pass=row->cells[columnIndex]->i<inclusionFilters[j].cellValue->i;
break;
//.........这里部分代码省略.........
开发者ID:bazhenovc,项目名称:nebula3,代码行数:101,代码来源:DS_Table.cpp
示例15: QueryTable
void Table::QueryTable(unsigned *columnIndicesSubset, unsigned numColumnSubset, FilterQuery *inclusionFilters, unsigned numInclusionFilters, unsigned *rowIds, unsigned numRowIDs, Table *result)
{
unsigned i;
DataStructures::List<unsigned> columnIndicesToReturn;
// Clear the result table.
result->Clear();
if (columnIndicesSubset && numColumnSubset>0)
{
for (i=0; i < numColumnSubset; i++)
{
if (columnIndicesSubset[i]>=0 && columnIndicesSubset[i]<columns.Size())
columnIndicesToReturn.Insert(columnIndicesSubset[i]);
}
}
else
{
for (i=0; i < columns.Size(); i++)
columnIndicesToReturn.Insert(i);
}
if (columnIndicesToReturn.Size()==0)
return; // No valid columns specified
for (i=0; i < columnIndicesToReturn.Size(); i++)
{
result->AddColumn(columns[columnIndicesToReturn[i]].columnName,columns[columnIndicesToReturn[i]].columnType);
}
// Get the column indices of the filter queries.
DataStructures::List<unsigned> inclusionFilterColumnIndices;
if (inclusionFilters && numInclusionFilters>0)
{
for (i=0; i < numInclusionFilters; i++)
{
if (inclusionFilters[i].columnName[0])
inclusionFilters[i].columnIndex=ColumnIndex(inclusionFilters[i].columnName);
if (inclusionFilters[i].columnIndex>=0 && inclusionFilters[i].columnIndex<columns.Size())
inclusionFilterColumnIndices.Insert(inclusionFilters[i].columnIndex);
else
inclusionFilterColumnIndices.Insert((unsigned)-1);
}
}
if (rowIds==0 || numRowIDs==0)
{
// All rows
DataStructures::Page<unsigned, Row*, _TABLE_BPLUS_TREE_ORDER> *cur = rows.GetListHead();
while (cur)
{
for (i=0; i < (unsigned)cur->size; i++)
{
QueryRow(inclusionFilterColumnIndices, columnIndicesToReturn, cur->keys[i], cur->data[i], inclusionFilters, result);
}
cur=cur->next;
}
}
else
{
// Specific rows
Row *row;
for (i=0; i < numRowIDs; i++)
{
if (rows.Get(rowIds[i], row))
{
QueryRow(inclusionFilterColumnIndices, columnIndicesToReturn, rowIds[i], row, inclusionFilters, result);
}
}
}
}
开发者ID:bazhenovc,项目名称:nebula3,代码行数:71,代码来源:DS_Table.cpp
示例16: OnReceive
PluginReceiveResult NatPunchthroughServer::OnReceive(Packet *packet)
{
switch (packet->data[0])
{
case ID_NAT_PUNCHTHROUGH_REQUEST:
OnNATPunchthroughRequest(packet);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
case ID_NAT_GET_MOST_RECENT_PORT:
OnGetMostRecentPort(packet);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
case ID_NAT_CLIENT_READY:
OnClientReady(packet);
return RR_STOP_PROCESSING_AND_DEALLOCATE;
case ID_NAT_REQUEST_BOUND_ADDRESSES:
{
RakNet::BitStream outgoingBs;
outgoingBs.Write((MessageID)ID_NAT_RESPOND_BOUND_ADDRESSES);
if (boundAddresses[0]==UNASSIGNED_SYSTEM_ADDRESS)
{
DataStructures::List<RakNetSocket2* > sockets;
rakPeerInterface->GetSockets(sockets);
for (int i=0; i < sockets.Size() && i < MAXIMUM_NUMBER_OF_INTERNAL_IDS; i++)
{
boundAddresses[i]=sockets[i]->GetBoundAddress();
boundAddressCount++;
}
}
outgoingBs.Write(boundAddressCount);
for (int i=0; i < boundAddressCount; i++)
{
outgoingBs.Write(boundAddresses[i]);
}
rakPeerInterface->Send(&outgoingBs,HIGH_PRIORITY,RELIABLE_ORDERED,0,packet->systemAddress,false);
}
return RR_STOP_PROCESSING_AND_DEALLOCATE;
case ID_NAT_PING:
{
}
return RR_STOP_PROCESSING_AND_DEALLOCATE;
case ID_OUT_OF_BAND_INTERNAL:
if (packet->length>=2 && packet->data[1]==ID_NAT_PING)
{
RakNet::BitStream bs(packet->data,packet->length,false);
bs.IgnoreBytes(sizeof(MessageID)*2);
uint16_t externalPort;
bs.Read(externalPort);
RakNet::BitStream outgoingBs;
outgoingBs.Write((MessageID)ID_NAT_PONG);
outgoingBs.Write(externalPort);
uint16_t externalPort2 = packet->systemAddress.GetPort();
outgoingBs.Write(externalPort2);
rakPeerInterface->SendOutOfBand((const char*) packet->systemAddress.ToString(false),packet->systemAddress.GetPort(),(const char*) outgoingBs.GetData(),outgoingBs.GetNumberOfBytesUsed());
return RR_STOP_PROCESSING_AND_DEALLOCATE;
}
}
return RR_CONTINUE_PROCESSING;
}
开发者ID:Aasagi,项目名称:DICEProgrammingChallenge,代码行数:62,代码来源:NatPunchthroughServer.cpp
示例17: Update
void StatisticsHistoryPlugin::Update(void)
{
DataStructures::List<SystemAddress> addresses;
DataStructures::List<RakNetGUID> guids;
DataStructures::List<RakNetStatistics> stats;
rakPeerInterface->GetStatisticsList(addresses, guids, stats);
Time curTime = GetTime();
for (unsigned int idx = 0; idx < guids.Size(); idx++)
{
unsigned int objectIndex = statistics.GetObjectIndex(guids[idx].g);
if (objectIndex!=(unsigned int)-1)
{
statistics.AddValueByIndex(objectIndex,
"RN_ACTUAL_BYTES_SENT",
(SHValueType) stats[idx].valueOverLastSecond[ACTUAL_BYTES_SENT],
curTime, false);
statistics.AddValueByIndex(objectIndex,
"RN_USER_MESSAGE_BYTES_RESENT",
(SHValueType) stats[idx].valueOverLastSecond[USER_MESSAGE_BYTES_RESENT],
curTime, false);
statistics.AddValueByIndex(objectIndex,
"RN_ACTUAL_BYTES_RECEIVED",
(SHValueType) stats[idx].valueOverLastSecond[ACTUAL_BYTES_RECEIVED],
curTime, false);
statistics.AddValueByIndex(objectIndex,
"RN_USER_MESSAGE_BYTES_PUSHED",
(SHValueType) stats[idx].valueOverLastSecond[USER_MESSAGE_BYTES_PUSHED],
curTime, false);
statistics.AddValueByIndex(objectIndex,
"RN_USER_MESSAGE_BYTES_RECEIVED_PROCESSED",
(SHValueType) stats[idx].valueOverLastSecond[USER_MESSAGE_BYTES_RECEIVED_PROCESSED],
curTime, false);
statistics.AddValueByIndex(objectIndex,
"RN_lastPing",
(SHValueType) rakPeerInterface->GetLastPing(guids[idx]),
curTime, false);
statistics.AddValueByIndex(objectIndex,
"RN_bytesInResendBuffer",
(SHValueType) stats[idx].bytesInResendBuffer,
curTime, false);
statistics.AddValueByIndex(objectIndex,
"RN_packetlossLastSecond",
(SHValueType) stats[idx].packetlossLastSecond,
curTime, false);
}
}
/*
RakNetStatistics rns;
DataStructures::List<SystemAddress> addresses;
DataStructures::List<RakNetGUID> guids;
rakPeerInterface->GetSystemList(addresses, guids);
for (unsigned int idx = 0; idx < guids.Size(); idx++)
{
rakPeerInterface->GetStatistics(remoteSystems[idx], &rns);
statistics.AddValue();
bool AddValue(uint64_t objectId, RakString key, SHValueType val, Time curTime);
}
*/
}
开发者ID:jochao,项目名称:HoloToolkit,代码行数:71,代码来源:StatisticsHistory.cpp
示例18: RunTest
/*
What is being done here is having 256 clients connect to one server, disconnect, connect again.
Do this for about 10 seconds. Then allow them all to connect for one last time.
This one has a nonblocking recieve so doesn't wait for connects or anything.
Just rapid connecting disconnecting.
Good ideas for changes:
After the last check run a eightpeers like test an add the conditions
of that test as well.
Make sure that if we initiate the connection we get a proper message
and if not we get a proper message. Add proper conditions.
Randomize sending the disconnect notes
Success conditions:
All connected normally.
Failure conditions:
Doesn't reconnect normally.
During the very first connect loop any connect returns false.
Connect function returns false and peer is not connected to anything.
*/
int ManyClientsOneServerNonBlockingTest::RunTest(DataStructures::List<RakString> params,bool isVerbose,bool noPauses)
{
const int clientNum= 256;
RakPeerInterface *clientList[clientNum];//A list of clients
RakPeerInterface *server;//The server
SystemAddress currentSystem;
//SystemAddress currentSystem;
Packet *packet;
destroyList.Clear(false,_FILE_AND_LINE_);
//Initializations of the arrays
for (int i=0;i<clientNum;i++)
{
clientList[i]=RakPeerInterface::GetInstance();
destroyList.Push(clientList[i],_FILE_AND_LINE_);
clientList[i]->Startup(1,&SocketDescriptor(), 1);
}
server=RakPeerInterface::GetInstance();
destroyList.Push(server,_FILE_AND_LINE_);
server->Startup(clientNum, &SocketDescriptor(60000,0), 1);
server->SetMaximumIncomingConnections(clientNum);
//Connect all the clients to the server
for (int i=0;i<clientNum;i++)
{
if (clientList[i]->Connect("127.0.0.1", 60000, 0,0)!=CONNECTION_ATTEMPT_STARTED)
{
if (isVerbose)
DebugTools::ShowError("Problem while calling connect.\n",!noPauses && isVerbose,__LINE__,__FILE__);
return 1;//This fails the test, don't bother going on.
}
}
TimeMS entryTime=GetTimeMS();//Loop entry time
DataStructures::List< SystemAddress > systemList;
DataStructures::List< RakNetGUID > guidList;
if (isVerbose)
printf("Entering disconnect loop \n");
while(GetTimeMS()-entryTime<10000)//Run for 10 Secoonds
{
//Disconnect all clients IF connected to any from client side
for (int i=0;i<clientNum;i++)
{
clientList[i]->GetSystemList(systemList,guidList);//Get connectionlist
int len=systemList.Size();
for (int j=0;j<len;j++)//Disconnect them all
{
clientList[i]->CloseConnection (systemList[j],true,0,LOW_PRIORITY);
}
}
//.........这里部分代码省略.........
开发者ID:jochao,项目名称:HoloToolkit,代码行数:101,代码来源:ManyClientsOneServerNonBlockingTest.cpp
示例19: main
_CONSOLE_2_SetSystemProcessParams
#endif
int main(void)
{
// Pointers to the interfaces of our server and client.
// Note we can easily have both in the same program
RakNet::RakPeerInterface *server=RakNet::RakPeerInterface::GetInstance();
RakNet::RakNetStatistics *rss;
server->SetIncomingPassword("Rumpelstiltskin", (int)strlen("Rumpelstiltskin"));
server->SetTimeoutTime(30000,RakNet::UNASSIGNED_SYSTEM_ADDRESS);
// RakNet::PacketLogger packetLogger;
// server->AttachPlugin(&packetLogger);
#if LIBCAT_SECURITY==1
cat::EasyHandshake handshake;
char public_key[cat::EasyHandshake::PUBLIC_KEY_BYTES];
char private_key[cat::EasyHandshake::PRIVATE_KEY_BYTES];
handshake.GenerateServerKey(public_key, private_key);
server->InitializeSecurity(public_key, private_key, false);
FILE *fp = fopen("publicKey.dat","wb");
fwrite(public_key,sizeof(public_key),1,fp);
fclose(fp);
#endif
// Holds packets
RakNet::Packet* p;
// GetPacketIdentifier returns this
unsigned char packetIdentifier;
// Record the first client that connects to us so we can pass it to the ping function
RakNet::SystemAddress clientID=RakNet::UNASSIGNED_SYSTEM_ADDRESS;
// Holds user data
char portstring[30];
printf("This is a sample implementation of a text based chat server.\n");
printf("Connect to the project 'Chat Example Client'.\n");
printf("Difficulty: Beginner\n\n");
// A server
puts("Enter the server port to listen on");
Gets(portstring,sizeof(portstring));
if (portstring[0]==0)
strcpy(portstring, "1234");
puts("Starting server.");
// Starting the server is very simple. 2 players allowed.
// 0 means we don't care about a connectionValidationInteger, and false
// for low priority threads
// I am creating two socketDesciptors, to create two sockets. One using IPV6 and the other IPV4
RakNet::SocketDescriptor socketDescriptors[2];
socketDescriptors[0].port=atoi(portstring);
socketDescriptors[0].socketFamily=AF_INET; // Test out IPV4
socketDescriptors[1].port=atoi(portstring);
socketDescriptors[1].socketFamily=AF_INET6; // Test out IPV6
bool b = server->Startup(4, socketDescriptors, 2 )==RakNet::RAKNET_STARTED;
server->SetMaximumIncomingConnections(4);
if (!b)
{
printf("Failed to start dual IPV4 and IPV6 ports. Trying IPV4 only.\n");
// Try again, but leave out IPV6
b = server->Startup(4, socketDescriptors, 1 )==RakNet::RAKNET_STARTED;
if (!b)
{
puts("Server failed to start. Terminating.");
exit(1);
}
}
server->SetOccasionalPing(true);
server->SetUnreliableTimeout(1000);
DataStructures::List< RakNet::RakNetSocket2* > sockets;
server->GetSockets(sockets);
printf("Socket addresses used by RakNet:\n");
for (unsigned int i=0; i < sockets.Size(); i++)
{
printf("%i. %s\n", i+1, sockets[i]->GetBoundAddress().ToString(true));
}
printf("\nMy IP addresses:\n");
for (unsigned int i=0; i < server->GetNumberOfAddresses(); i++)
{
RakNet::SystemAddress sa = server->GetInternalID(RakNet::UNASSIGNED_SYSTEM_ADDRESS, i);
printf("%i. %s (LAN=%i)\n", i+1, sa.ToString(false), sa.IsLANAddress());
}
printf("\nMy GUID is %s\n", server->GetGuidFromSystemAddress(RakNet::UNASSIGNED_SYSTEM_ADDRESS).ToString());
puts("'quit' to quit. 'stat' to show stats. 'ping' to ping.\n'pingip' to ping an ip address\n'ban' to ban an IP from connecting.\n'kick to kick the first connected player.\nType to talk.");
char message[2048];
// Loop for input
while (1)
{
// This sleep keeps RakNet responsive
RakSleep(30);
//.........这里部分代码省略.........
开发者ID:Darrenbydesign,项目名称:HoloToolkit,代码行数:101,代码来源:Chat+Example+Server.cpp
示例20: Init
bool TetrisServer::Init()
{
m_interface = RakNet::RakPeerInterface::GetInstance();
RakNet::RakNetStatistics *rss;
m_interface->SetIncomingPassword("Rumpelstiltskin", (int)strlen("Rumpelstiltskin"));
m_interface->SetTimeoutTime(30000, RakNet::UNASSIGNED_SYSTEM_ADDRESS);
// Record the first client that connects to us so we can pass it to the ping function
m_clientID = RakNet::UNASSIGNED_SYSTEM_ADDRESS;
// Holds user data
char* portstring = "1234";
printf("This is a sample implementation of a text based chat server.\n");
printf("Connect to the project 'Chat Example Client'.\n");
printf("Difficulty: Beginner\n\n");
printf("Starting server.\n");
// Starting the server is very simple. 2 players allowed.
// 0 means we don't care about a connectionValidationInteger, and false
// for low priority threads
// I am creating two socketDesciptors, to create two sockets. One using IPV6 and the other IPV4
RakNet::SocketDescriptor socketDescriptors[2];
socketDescriptors[0].port = atoi(portstring);
socketDescriptors[0].socketFamily = AF_INET; // Test out IPV4
socketDescriptors[1].port = atoi(portstring);
socketDescriptors[1].socketFamily = AF_INET6; // Test out IPV6
bool b = m_interface->Startup(4, socketDescriptors, 2) == RakNet::RAKNET_STARTED;
m_interface->SetMaximumIncomingConnections(4);
if (!b)
{
printf("Failed to start dual IPV4 and IPV6 ports. Trying IPV4 only.\n");
// Try again, but leave out IPV6
b = m_interface->Startup(4, socketDescriptors, 1) == RakNet::RAKNET_STARTED;
if (!b)
{
printf("Server failed to start. Terminating.\n");
return false;
}
}
m_interface->SetOccasionalPing(true);
m_interface->SetUnreliableTimeout(1000);
DataStructures::List< RakNet::RakNetSocket2* > sockets;
m_interface->GetSockets(sockets);
printf("Socket addresses used by RakNet:\n");
for (unsigned int i = 0; i < sockets.Size(); i++)
{
printf("%i. %s\n", i + 1, sockets[i]->GetBoundAddress().ToString(true));
}
printf("\nMy IP addresses:\n");
for (unsigned int i = 0; i < m_interface->GetNumberOfAddresses(); i++)
{
RakNet::SystemAddress sa = m_interface->GetInternalID(RakNet::UNASSIGNED_SYSTEM_ADDRESS, i);
printf("%i. %s (LAN=%i)\n", i + 1, sa.ToString(false), sa.IsLANAddress());
}
printf("\nMy GUID is %s\n", m_interface->GetGuidFromSystemAddress(RakNet::UNASSIGNED_SYSTEM_ADDRESS).ToString());
return true;
}
开发者ID:kmiron,项目名称:SFMLTetris,代码行数:62,代码来源:Networking.cpp
注:本文中的datastructures::List类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论