Beispiel #1
0
void CloudClient::OnSubscriptionNotification(Packet *packet, CloudClientCallback *_callback, CloudAllocator *_allocator)
{
	if (_callback==0)
		_callback=callback;
	if (_allocator==0)
		_allocator=allocator;

	bool wasUpdated=false;
	CloudQueryRow row;

	SLNet::BitStream bsIn(packet->data, packet->length, false);
	bsIn.IgnoreBytes(sizeof(MessageID));
	bsIn.Read(wasUpdated);
	row.Serialize(false,&bsIn,_allocator);
	bool deallocateRowAfterReturn=true;
	_callback->OnSubscriptionNotification(&row, wasUpdated, &deallocateRowAfterReturn);
	if (deallocateRowAfterReturn)
	{
		_allocator->DeallocateRowData(row.data);
	}
}
Beispiel #2
0
void CloudQueryResult::SerializeCloudQueryRows(bool writeToBitstream, uint32_t& numRows, BitStream* bitStream, CloudAllocator* allocator)
{
    if (writeToBitstream)
    {
        for (uint16_t i=0; i < numRows; i++)
        {
            rowsReturned[i]->Serialize(true,bitStream, allocator);
        }
    }
    else
    {
        CloudQueryRow* cmdr;

        for (uint16_t i=0; i < numRows; i++)
        {
            cmdr = allocator->AllocateCloudQueryRow();

            if (cmdr)
            {
                cmdr->Serialize(false,bitStream,allocator);

                if (cmdr->data==0 && cmdr->length>0)
                {
                    allocator->DeallocateCloudQueryRow(cmdr);
                    notifyOutOfMemory(_FILE_AND_LINE_);
                    numRows=i;
                    return;
                }

                rowsReturned.Push(cmdr, _FILE_AND_LINE_);
            }
            else
            {
                notifyOutOfMemory(_FILE_AND_LINE_);
                numRows=i;
                return;
            }
        }
    }
}