17 #if _RAKNET_SUPPORT_CloudServer==1 
   25 enum ServerToServerCommands
 
   27     STSC_PROCESS_GET_REQUEST,
 
   28     STSC_PROCESS_GET_RESPONSE,
 
   29     STSC_ADD_UPLOADED_AND_SUBSCRIBED_KEYS,
 
   30     STSC_ADD_UPLOADED_KEY,
 
   31     STSC_ADD_SUBSCRIBED_KEY,
 
   32     STSC_REMOVE_UPLOADED_KEY,
 
   33     STSC_REMOVE_SUBSCRIBED_KEY,
 
   37 using namespace SLNet;
 
   41     if (key < data->serverAddress)
 
   43     if (key > data->serverAddress)
 
   61     if (key < data->clientGUID)
 
   63     if (key > data->clientGUID)
 
   81     if (key < data->serverAddress)
 
   89     if (key < data->requestId)
 
  112         bitStream->
Read(specificSystemsCount);
 
  113         for (
uint16_t i=0; i < specificSystemsCount; i++)
 
  115             bitStream->
Read(addressOrGuid);
 
  123     for (i=0; i < remoteServerResponses.Size(); i++)
 
  124         if (remoteServerResponses[i]->gotResult==
false)
 
  131     for (i=0; i < remoteServerResponses.Size(); i++)
 
  133         remoteServerResponses[i]->Clear(allocator);
 
  141     for (i=0; i < queryResult.rowsReturned.Size(); i++)
 
  178             if (time - 
getRequests[i]->requestStartTime > 3000)
 
  195     switch (packet->
data[0])
 
  212             switch (packet->
data[1])
 
  214             case STSC_PROCESS_GET_REQUEST:
 
  217             case STSC_PROCESS_GET_RESPONSE:
 
  220             case STSC_ADD_UPLOADED_AND_SUBSCRIBED_KEYS:
 
  223             case STSC_ADD_UPLOADED_KEY:
 
  226             case STSC_ADD_SUBSCRIBED_KEY:
 
  229             case STSC_REMOVE_UPLOADED_KEY:
 
  232             case STSC_REMOVE_SUBSCRIBED_KEY:
 
  235             case STSC_DATA_CHANGED:
 
  251     bsIn.Read(dataLengthBytes);
 
  255     bsIn.AlignReadToByteBoundary();
 
  256     for (
unsigned int filterIndex=0; filterIndex < 
queryFilters.
Size(); filterIndex++)
 
  271         bsIn.ReadAlignedBytes(data,dataLengthBytes);
 
  278     RemoteCloudClient *remoteCloudClient;
 
  283         remoteCloudClient->uploadedBytes=0;
 
  292         if (objectExists==
false)
 
  294             remoteCloudClient->uploadedKeys.InsertAtIndex(key, uploadedKeysIndex, 
_FILE_AND_LINE_);
 
  298     bool cloudDataAlreadyUploaded;
 
  299     unsigned int dataRepositoryIndex;
 
  300     bool dataRepositoryExists;
 
  302     if (dataRepositoryExists==
false)
 
  304         cloudDataList->uploaderCount=1;
 
  305         cloudDataAlreadyUploaded=
false;
 
  309         cloudDataAlreadyUploaded=cloudDataList->uploaderCount>0;
 
  310         cloudDataList->uploaderCount++;
 
  313     CloudData *cloudData;
 
  314     bool keyDataListExists;
 
  315     unsigned int keyDataListIndex = cloudDataList->keyData.GetIndexFromKey(packet->
guid, &keyDataListExists);
 
  316     if (keyDataListExists==
false)
 
  321             if (keyDataListExists==
false)
 
  327             if (remoteCloudClient->IsUnused())
 
  340         cloudData->dataLengthBytes=dataLengthBytes;
 
  341         cloudData->isUploaded=
true;
 
  350             if (cloudData->serverSystemAddress.IsLoopback())
 
  353         if (cloudData->serverSystemAddress.GetPort()==0)
 
  360         cloudData->clientGUID=packet->
guid;
 
  365         cloudData = cloudDataList->keyData[keyDataListIndex];
 
  367         if (cloudDataAlreadyUploaded==
false)
 
  378             if (cloudData->serverSystemAddress.GetPort()==0)
 
  390             if (dataRepositoryExists==
false)
 
  400             remoteCloudClient->uploadedBytes-=cloudData->dataLengthBytes;
 
  403         if (cloudData->allocatedData!=0)
 
  410         cloudData->allocatedData=data;
 
  411         cloudData->dataPtr=data;
 
  416         if (dataLengthBytes>0)
 
  417             bsIn.ReadAlignedBytes(cloudData->stackData,dataLengthBytes);
 
  418         cloudData->allocatedData=0;
 
  419         cloudData->dataPtr=cloudData->stackData;
 
  422     cloudData->dataLengthBytes=dataLengthBytes;
 
  423     remoteCloudClient->uploadedBytes+=dataLengthBytes;
 
  425     if (cloudDataAlreadyUploaded==
false)
 
  463     for (
uint16_t keyCountIndex=0; keyCountIndex < keyCount; keyCountIndex++)
 
  469     for (
unsigned int filterIndex=0; filterIndex < 
queryFilters.
Size(); filterIndex++)
 
  475     for (
uint16_t keyCountIndex=0; keyCountIndex < keyCount; keyCountIndex++)
 
  479         key=cloudKeys[keyCountIndex];
 
  483         unsigned int uploadedKeysIndex = remoteCloudClient->uploadedKeys.GetIndexFromKey(key,&objectExists);
 
  486             bool dataRepositoryExists;
 
  488             CloudDataList* cloudDataList = 
dataRepository[dataRepositoryIndex];
 
  491             CloudData *cloudData;
 
  492             bool keyDataListExists;
 
  493             unsigned int keyDataListIndex = cloudDataList->keyData.GetIndexFromKey(packet->
guid, &keyDataListExists);
 
  494             cloudData = cloudDataList->keyData[keyDataListIndex];
 
  496             remoteCloudClient->uploadedKeys.RemoveAtIndex(uploadedKeysIndex);
 
  497             remoteCloudClient->uploadedBytes-=cloudData->dataLengthBytes;
 
  498             cloudDataList->uploaderCount--;
 
  507             if (cloudData->IsUnused())
 
  510                 cloudDataList->keyData.RemoveAtIndex(keyDataListIndex);
 
  511                 if (cloudDataList->IsNotUploaded())
 
  517                 if (cloudDataList->IsUnused())
 
  524             if (remoteCloudClient->IsUnused())
 
  541     GetRequest *getRequest;
 
  543     getRequest->cloudQueryWithAddresses.cloudQuery.
Serialize(
false, &bsIn);
 
  544     getRequest->requestingClient=packet->
guid;
 
  547     bsIn.Read(specificSystemsCount);
 
  548     for (
uint16_t i=0; i < specificSystemsCount; i++)
 
  550         bsIn.Read(addressOrGuid);
 
  551         getRequest->cloudQueryWithAddresses.specificSystems.Push(addressOrGuid, 
_FILE_AND_LINE_);
 
  554     if (getRequest->cloudQueryWithAddresses.cloudQuery.keys.Size()==0)
 
  560     for (
unsigned int filterIndex=0; filterIndex < 
queryFilters.
Size(); filterIndex++)
 
  573     if (remoteServersWithData.
Size()==0)
 
  582         getRequest->cloudQueryWithAddresses.Serialize(
true, &bsOut);
 
  583         bsOut.
Write(getRequest->requestId);
 
  585         for (
unsigned int remoteServerIndex=0; remoteServerIndex < remoteServersWithData.
Size(); remoteServerIndex++)
 
  587             BufferedGetResponseFromServer* bufferedGetResponseFromServer = SLNet::OP_NEW<BufferedGetResponseFromServer>(
_FILE_AND_LINE_);
 
  588             bufferedGetResponseFromServer->serverAddress=remoteServersWithData[remoteServerIndex]->serverAddress;
 
  589             bufferedGetResponseFromServer->gotResult=
false;
 
  590             getRequest->remoteServerResponses.
Insert(remoteServersWithData[remoteServerIndex]->serverAddress, bufferedGetResponseFromServer, 
true, 
_FILE_AND_LINE_);
 
  599     if (getRequest->cloudQueryWithAddresses.cloudQuery.subscribeToResults)
 
  603         RemoteCloudClient *remoteCloudClient;
 
  607             remoteCloudClient->uploadedBytes=0;
 
  615         unsigned int keyIndex;
 
  616         for (keyIndex=0; keyIndex < getRequest->cloudQueryWithAddresses.cloudQuery.keys.Size(); keyIndex++)
 
  618             cloudKey = getRequest->cloudQueryWithAddresses.cloudQuery.keys[keyIndex];
 
  620             unsigned int keySubscriberIndex;
 
  621             bool hasKeySubscriber;
 
  622             keySubscriberIndex = remoteCloudClient->subscribedKeys.GetIndexFromKey(cloudKey, &hasKeySubscriber);
 
  623             KeySubscriberID* keySubscriberId;
 
  624             if (hasKeySubscriber)
 
  631             keySubscriberId->key=cloudKey;
 
  633             unsigned int specificSystemIndex;
 
  634             for (specificSystemIndex=0; specificSystemIndex < getRequest->cloudQueryWithAddresses.specificSystems.Size(); specificSystemIndex++)
 
  636                 keySubscriberId->specificSystemsSubscribedTo.Insert(getRequest->cloudQueryWithAddresses.specificSystems[specificSystemIndex], getRequest->cloudQueryWithAddresses.specificSystems[specificSystemIndex], 
true, 
_FILE_AND_LINE_);
 
  639             remoteCloudClient->subscribedKeys.InsertAtIndex(keySubscriberId, keySubscriberIndex, 
_FILE_AND_LINE_);
 
  642             unsigned int dataRepositoryIndex;
 
  643             bool dataRepositoryExists;
 
  647             if (cloudDataList->subscriberCount==0)
 
  651             if (getRequest->cloudQueryWithAddresses.specificSystems.Size())
 
  653                 CloudData *cloudData;
 
  654                 bool keyDataListExists;
 
  656                 for (specificSystemIndex=0; specificSystemIndex < getRequest->cloudQueryWithAddresses.specificSystems.Size(); specificSystemIndex++)
 
  658                     RakNetGUID specificSystem = getRequest->cloudQueryWithAddresses.specificSystems[specificSystemIndex];
 
  660                     unsigned int keyDataListIndex = cloudDataList->keyData.GetIndexFromKey(specificSystem, &keyDataListExists);
 
  661                     if (keyDataListExists==
false)
 
  664                         cloudData->dataLengthBytes=0;
 
  665                         cloudData->allocatedData=0;
 
  666                         cloudData->isUploaded=
false;
 
  667                         cloudData->dataPtr=0;
 
  671                         cloudData->clientGUID=specificSystem;
 
  672                         cloudDataList->keyData.Insert(specificSystem,cloudData,
true,
_FILE_AND_LINE_);
 
  676                         cloudData = cloudDataList->keyData[keyDataListIndex];
 
  679                     ++cloudDataList->subscriberCount;
 
  685                 ++cloudDataList->subscriberCount;
 
  689                 unsigned int subscribedKeysIndex;
 
  690                 bool subscribedKeysIndexExists;
 
  691                 subscribedKeysIndex = remoteCloudClient->subscribedKeys.GetIndexFromKey(cloudDataList->key, &subscribedKeysIndexExists);
 
  692                 if (subscribedKeysIndexExists)
 
  694                     keySubscriberId = remoteCloudClient->subscribedKeys[subscribedKeysIndex];
 
  695                     for (specificSystemIndex=0; specificSystemIndex < keySubscriberId->specificSystemsSubscribedTo.Size(); specificSystemIndex++)
 
  698                         unsigned int keyDataIndex = cloudDataList->keyData.GetIndexFromKey(keySubscriberId->specificSystemsSubscribedTo[specificSystemIndex], &keyDataExists);
 
  701                             CloudData *keyData = cloudDataList->keyData[keyDataIndex];
 
  702                             keyData->specificSubscribers.Remove(packet->
guid);
 
  703                             --cloudDataList->subscriberCount;
 
  710         if (remoteCloudClient->subscribedKeys.Size()==0)
 
  718     if (remoteServersWithData.
Size()==0)
 
  732     uint16_t keyCount, specificSystemCount;
 
  739     for (index=0; index < keyCount; index++)
 
  746     bsIn.Read(specificSystemCount);
 
  747     for (index=0; index < specificSystemCount; index++)
 
  749         bsIn.Read(specificSystem);
 
  753     for (
unsigned int filterIndex=0; filterIndex < 
queryFilters.
Size(); filterIndex++)
 
  760     bool dataRepositoryExists;
 
  763     for (index=0; index < keyCount; index++)
 
  765         cloudKey = cloudKeys[index];
 
  769         if (dataRepositoryExists==
false)
 
  773         unsigned int keySubscriberIndex;
 
  774         bool hasKeySubscriber;
 
  775         keySubscriberIndex = remoteCloudClient->subscribedKeys.GetIndexFromKey(cloudKey, &hasKeySubscriber);
 
  777         if (hasKeySubscriber==
false)
 
  783     if (remoteCloudClient->IsUnused())
 
  795     if (objectExists==
false)
 
  801     CloudQueryWithAddresses cloudQueryWithAddresses;
 
  803     cloudQueryWithAddresses.Serialize(
false, &bsIn);
 
  804     bsIn.Read(requestId);
 
  813     bsOut.
Write(requestId);
 
  819     unsigned int remoteServerIndex;
 
  822     if (objectExists==
false)
 
  825     RemoteServer *remoteServer = 
remoteServers[remoteServerIndex];
 
  833     bsIn.Read(requestId);
 
  837     unsigned int getRequestIndex;
 
  839     if (hasGetRequest==
false)
 
  841     GetRequest *getRequest = 
getRequests[getRequestIndex];
 
  842     bool hasRemoteServer;
 
  843     unsigned int remoteServerResponsesIndex;
 
  844     remoteServerResponsesIndex = getRequest->remoteServerResponses.
GetIndexFromKey(packet->
guid, &hasRemoteServer);
 
  845     if (hasRemoteServer==
false)
 
  847     BufferedGetResponseFromServer *bufferedGetResponseFromServer;
 
  848     bufferedGetResponseFromServer = getRequest->remoteServerResponses[remoteServerResponsesIndex];
 
  849     if (bufferedGetResponseFromServer->gotResult==
true)
 
  851     bufferedGetResponseFromServer->gotResult=
true;
 
  853     bufferedGetResponseFromServer->queryResult.SerializeNumRows(
false, numRows, &bsIn);
 
  854     bufferedGetResponseFromServer->queryResult.SerializeCloudQueryRows(
false, numRows, &bsIn, 
this);
 
  857     if (getRequest->AllRemoteServersHaveResponded())
 
  861         getRequest->Clear(
this);
 
  869     (void) lostConnectionReason;
 
  870     (void) systemAddress;
 
  872     unsigned int remoteServerIndex;
 
  878         unsigned int getRequestIndex=0;
 
  881             GetRequest *getRequest = 
getRequests[getRequestIndex];
 
  882             bool waitingForThisServer;
 
  883             unsigned int remoteServerResponsesIndex = getRequest->remoteServerResponses.
GetIndexFromKey(rakNetGUID, &waitingForThisServer);
 
  884             if (waitingForThisServer)
 
  886                 getRequest->remoteServerResponses[remoteServerResponsesIndex]->Clear(
this);
 
  888                 getRequest->remoteServerResponses.RemoveAtIndex(remoteServerResponsesIndex);
 
  890                 if (getRequest->AllRemoteServersHaveResponded())
 
  893                     getRequest->Clear(
this);
 
  910     if (remoteSystemIndex.
IsInvalid()==
false)
 
  913         unsigned int uploadedKeysIndex;
 
  914         for (uploadedKeysIndex=0; uploadedKeysIndex < remoteCloudClient->uploadedKeys.Size(); uploadedKeysIndex++)
 
  917             bool keyDataRepositoryExists;
 
  918             unsigned int dataRepositoryIndex = 
dataRepository.
GetIndexFromKey(remoteCloudClient->uploadedKeys[uploadedKeysIndex], &keyDataRepositoryExists);
 
  919             if (keyDataRepositoryExists)
 
  921                 CloudDataList* cloudDataList = 
dataRepository[dataRepositoryIndex];
 
  923                 unsigned int keyDataIndex = cloudDataList->keyData.
GetIndexFromKey(rakNetGUID, &keyDataExists);
 
  926                     CloudData *cloudData = cloudDataList->keyData[keyDataIndex];
 
  927                     cloudDataList->uploaderCount--;
 
  935                     if (cloudData->IsUnused())
 
  938                         cloudDataList->keyData.RemoveAtIndex(keyDataIndex);
 
  940                         if (cloudDataList->IsNotUploaded())
 
  946                         if (cloudDataList->IsUnused())
 
  959         unsigned int subscribedKeysIndex;
 
  960         for (subscribedKeysIndex=0; subscribedKeysIndex < remoteCloudClient->subscribedKeys.Size(); subscribedKeysIndex++)
 
  962             KeySubscriberID* keySubscriberId;
 
  963             keySubscriberId = remoteCloudClient->subscribedKeys[subscribedKeysIndex];
 
  965             bool keyDataRepositoryExists;
 
  966             unsigned int keyDataRepositoryIndex = 
dataRepository.
GetIndexFromKey(remoteCloudClient->subscribedKeys[subscribedKeysIndex]->key, &keyDataRepositoryExists);
 
  967             if (keyDataRepositoryExists)
 
  969                 CloudDataList* cloudDataList = 
dataRepository[keyDataRepositoryIndex];
 
  970                 if (keySubscriberId->specificSystemsSubscribedTo.Size()==0)
 
  972                     cloudDataList->nonSpecificSubscribers.
Remove(rakNetGUID);
 
  973                     --cloudDataList->subscriberCount;
 
  977                     unsigned int specificSystemIndex;
 
  978                     for (specificSystemIndex=0; specificSystemIndex < keySubscriberId->specificSystemsSubscribedTo.Size(); specificSystemIndex++)
 
  981                         unsigned int keyDataIndex = cloudDataList->keyData.GetIndexFromKey(keySubscriberId->specificSystemsSubscribedTo[specificSystemIndex], &keyDataExists);
 
  984                             CloudData *keyData = cloudDataList->keyData[keyDataIndex];
 
  985                             keyData->specificSubscribers.Remove(rakNetGUID);
 
  986                             --cloudDataList->subscriberCount;
 
 1010         for (j=0; j < cloudDataList->keyData.Size(); j++)
 
 1012             cloudDataList->keyData[j]->
Clear();
 
 1028         getRequest->
Clear(
this);
 
 1036     for (i=0; i < itemList.
Size(); i++)
 
 1038         RemoteCloudClient* remoteCloudClient = itemList[i];
 
 1039         for (j=0; j < remoteCloudClient->subscribedKeys.Size(); j++)
 
 1051     for (i=0; i < cloudKeyResultList.
Size(); i++)
 
 1059     CloudData *cloudData = cloudDataResultList[i];
 
 1060     cloudQueryRow.
key=cloudKeyResultList[i];
 
 1061     cloudQueryRow.
data=cloudData->dataPtr;
 
 1062     cloudQueryRow.
length=cloudData->dataLengthBytes;
 
 1065     cloudQueryRow.
serverGUID=cloudData->serverGUID;
 
 1066     cloudQueryRow.
clientGUID=cloudData->clientGUID;
 
 1067     cloudQueryRow.
Serialize(
true, bsOut, 0);
 
 1073     bsOut.
Write(wasUpdated);
 
 1076     row.
data=cloudData->dataPtr;
 
 1077     row.
length=cloudData->dataLengthBytes;
 
 1085     for (i=0; i < subscribers.
Size(); i++)
 
 1094     bsOut.
Write(wasUpdated);
 
 1098     for (i=0; i < subscribers.
Size(); i++)
 
 1110     bsOut.
Write(wasUpdated);
 
 1113     row.
data=cloudData->dataPtr;
 
 1114     row.
length=cloudData->dataLengthBytes;
 
 1137     if (objectExists==
false)
 
 1139         RemoteServer *remoteServer = SLNet::OP_NEW<RemoteServer>(
_FILE_AND_LINE_);
 
 1140         remoteServer->gotSubscribedAndUploadedKeys=
false;
 
 1141         remoteServer->serverAddress=systemIdentifier;
 
 1151     if (objectExists==
true)
 
 1174     cloudQueryResult.
cloudQuery=getRequest->cloudQueryWithAddresses.cloudQuery;
 
 1175     cloudQueryResult.
subscribeToResults=getRequest->cloudQueryWithAddresses.cloudQuery.subscribeToResults;
 
 1181     bool unlimitedRows=getRequest->cloudQueryWithAddresses.cloudQuery.maxRowsToReturn==0;
 
 1184     if (unlimitedRows==
false &&
 
 1185         localNumRows > getRequest->cloudQueryWithAddresses.cloudQuery.startingRowIndex &&
 
 1186         localNumRows - getRequest->cloudQueryWithAddresses.cloudQuery.startingRowIndex > getRequest->cloudQueryWithAddresses.cloudQuery.maxRowsToReturn )
 
 1187         localNumRows=getRequest->cloudQueryWithAddresses.cloudQuery.startingRowIndex + getRequest->cloudQueryWithAddresses.cloudQuery.maxRowsToReturn;
 
 1191     unsigned int skipRows;
 
 1192     if (localNumRows>getRequest->cloudQueryWithAddresses.cloudQuery.startingRowIndex)
 
 1194         localRowsToWrite=localNumRows-getRequest->cloudQueryWithAddresses.cloudQuery.startingRowIndex;
 
 1200         skipRows=getRequest->cloudQueryWithAddresses.cloudQuery.startingRowIndex-localNumRows;
 
 1203     for (
unsigned int i=getRequest->cloudQueryWithAddresses.cloudQuery.startingRowIndex; i < localNumRows; i++)
 
 1209     if (unlimitedRows==
true || getRequest->cloudQueryWithAddresses.cloudQuery.maxRowsToReturn>localRowsToWrite)
 
 1213         if (unlimitedRows==
false)
 
 1214             remainingRows=getRequest->cloudQueryWithAddresses.cloudQuery.maxRowsToReturn-localRowsToWrite;
 
 1216         unsigned int remoteServerResponseIndex;
 
 1217         for (remoteServerResponseIndex=0; remoteServerResponseIndex < getRequest->remoteServerResponses.Size(); remoteServerResponseIndex++)
 
 1219             BufferedGetResponseFromServer *bufferedGetResponseFromServer = getRequest->remoteServerResponses[remoteServerResponseIndex];
 
 1220             unsigned int cloudQueryRowIndex;
 
 1221             for (cloudQueryRowIndex=0; cloudQueryRowIndex < bufferedGetResponseFromServer->queryResult.rowsReturned.Size(); cloudQueryRowIndex++)
 
 1228                 bufferedGetResponseFromServer->queryResult.rowsReturned[cloudQueryRowIndex]->Serialize(
true, &bsOut, 
this);
 
 1230                 ++additionalRowsWritten;
 
 1231                 if (unlimitedRows==
false && --remainingRows==0)
 
 1235             if (unlimitedRows==
false && remainingRows==0)
 
 1239         if (additionalRowsWritten>0)
 
 1243             localRowsToWrite+=additionalRowsWritten;
 
 1255     unsigned int queryIndex;
 
 1256     bool dataRepositoryExists;
 
 1257     CloudDataList* cloudDataList;
 
 1258     unsigned int keyDataIndex;
 
 1262     for (queryIndex=0; queryIndex < cloudQueryWithAddresses.
cloudQuery.
keys.
Size(); queryIndex++)
 
 1267         if (dataRepositoryExists)
 
 1271             if (cloudDataList->uploaderCount>0)
 
 1277                     unsigned int specificSystemIndex;
 
 1278                     for (specificSystemIndex=0; specificSystemIndex < cloudQueryWithAddresses.
specificSystems.
Size(); specificSystemIndex++)
 
 1280                         bool uploaderExists;
 
 1292                     for (keyDataIndex=0; keyDataIndex < cloudDataList->keyData.Size(); keyDataIndex++)
 
 1320             subscribedKeyCount++;
 
 1374     if (objectExists==
false)
 
 1377     remoteServer->gotSubscribedAndUploadedKeys=
true;
 
 1381     uint16_t numUploadedKeys, numSubscribedKeys;
 
 1382     bsIn.Read(numUploadedKeys);
 
 1383     for (
uint16_t i=0; i < numUploadedKeys; i++)
 
 1389             remoteServer->uploadedKeys.GetIndexFromKey(cloudKey, &alreadyHasKey);
 
 1390         if (alreadyHasKey==
false)
 
 1391             remoteServer->uploadedKeys.Insert(cloudKey,cloudKey,
true,
_FILE_AND_LINE_);
 
 1394     bsIn.Read(numSubscribedKeys);
 
 1395     for (
uint16_t i=0; i < numSubscribedKeys; i++)
 
 1401             remoteServer->subscribedKeys.GetIndexFromKey(cloudKey, &alreadyHasKey);
 
 1402         if (alreadyHasKey==
false)
 
 1403             remoteServer->subscribedKeys.Insert(cloudKey,cloudKey,
true,
_FILE_AND_LINE_);
 
 1417     if (objectExists==
false)
 
 1425         remoteServer->uploadedKeys.GetIndexFromKey(cloudKey, &alreadyHasKey);
 
 1426     if (alreadyHasKey==
false)
 
 1427         remoteServer->uploadedKeys.Insert(cloudKey,cloudKey,
true,
_FILE_AND_LINE_);
 
 1436     if (objectExists==
false)
 
 1444         remoteServer->subscribedKeys.GetIndexFromKey(cloudKey, &alreadyHasKey);
 
 1447     if (alreadyHasKey==
false)
 
 1448         remoteServer->subscribedKeys.Insert(cloudKey,cloudKey,
true,
_FILE_AND_LINE_);
 
 1457     if (objectExists==
false)
 
 1462     unsigned int insertionIndex;
 
 1464     insertionIndex = remoteServer->uploadedKeys.GetIndexFromKey(cloudKey, &alreadyHasKey);
 
 1465     if (alreadyHasKey==
true)
 
 1466         remoteServer->uploadedKeys.RemoveAtIndex(insertionIndex);
 
 1475     if (objectExists==
false)
 
 1480     unsigned int insertionIndex;
 
 1482     insertionIndex = remoteServer->subscribedKeys.GetIndexFromKey(cloudKey, &alreadyHasKey);
 
 1483     if (alreadyHasKey==
true)
 
 1484         remoteServer->subscribedKeys.RemoveAtIndex(insertionIndex);
 
 1493     if (objectExists==
false)
 
 1497     bool wasUpdated=
false;
 
 1498     bsIn.Read(wasUpdated);
 
 1502     CloudDataList *cloudDataList;
 
 1503     bool dataRepositoryExists;
 
 1504     unsigned int dataRepositoryIndex;
 
 1506     if (dataRepositoryExists==
false)
 
 1512     CloudData *cloudData;
 
 1513     bool keyDataListExists;
 
 1515     if (keyDataListExists==
true)
 
 1517         cloudData = cloudDataList->keyData[keyDataListIndex];
 
 1549                 for (j=0; j < keys.
Size(); j++)
 
 1565     CloudDataList *cloudDataList;
 
 1568     if (*dataRepositoryExists==
false)
 
 1571         cloudDataList->key=key;
 
 1572         cloudDataList->uploaderCount=0;
 
 1573         cloudDataList->subscriberCount=0;
 
 1581     return cloudDataList;
 
 1586     KeySubscriberID* keySubscriberId = remoteCloudClient->subscribedKeys[keySubscriberIndex];
 
 1589     if (keySubscriberId->specificSystemsSubscribedTo.Size()==0 && specificSystems.
Size()>0)
 
 1592     bool dataRepositoryExists;
 
 1593     CloudDataList *cloudDataList;
 
 1595     if (dataRepositoryExists==
false)
 
 1601     if (specificSystems.
Size()==0)
 
 1604         if (cloudDataList->RemoveSubscriber(remoteCloudClientGuid)==
false)
 
 1606             for (i=0; i < keySubscriberId->specificSystemsSubscribedTo.Size(); i++)
 
 1611         keySubscriberId->specificSystemsSubscribedTo.Clear(
true, 
_FILE_AND_LINE_);
 
 1615         for (j=0; j < specificSystems.
Size(); j++)
 
 1617             unsigned int specificSystemsSubscribedToIndex;
 
 1618             bool hasSpecificSystemsSubscribedTo;
 
 1619             specificSystemsSubscribedToIndex=keySubscriberId->specificSystemsSubscribedTo.GetIndexFromKey(specificSystems[j], &hasSpecificSystemsSubscribedTo);
 
 1620             if (hasSpecificSystemsSubscribedTo)
 
 1623                 keySubscriberId->specificSystemsSubscribedTo.RemoveAtIndex(specificSystemsSubscribedToIndex);
 
 1628     if (keySubscriberId->specificSystemsSubscribedTo.Size()==0)
 
 1631         remoteCloudClient->subscribedKeys.RemoveAtIndex(keySubscriberIndex);
 
 1634     if (cloudDataList->subscriberCount==0)
 
 1637     if (cloudDataList->IsUnused())
 
 1645     bool keyDataListExists;
 
 1646     unsigned int keyDataListIndex = cloudDataList->keyData.GetIndexFromKey(specificSubscriber, &keyDataListExists);
 
 1647     if (keyDataListExists==
false)
 
 1649     CloudData *cloudData = cloudDataList->keyData[keyDataListIndex];
 
 1650     bool hasSpecificSubscriber;
 
 1651     unsigned int specificSubscriberIndex = cloudData->specificSubscribers.GetIndexFromKey(remoteCloudClientGuid, &hasSpecificSubscriber);
 
 1652     if (hasSpecificSubscriber)
 
 1654         cloudData->specificSubscribers.RemoveAtIndex(specificSubscriberIndex);
 
 1655         cloudDataList->subscriberCount--;
 
 1657         if (cloudData->IsUnused())
 
 1660             cloudDataList->keyData.RemoveAtIndex(keyDataListIndex);
 
 1679     if (index != (
unsigned int) -1)