⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gsdpqueue.cpp

📁 Symbian mobile os C++ GSDP编程
💻 CPP
字号:
// gsdpqueue.cpp
//
// Basic Queue for the GSDP server
//
// Copyright (c) 2000-2002 Symbian Ltd.  All rights reserved.

#include "gsdpqueue.h"

/*
	CGsdpQueueBase
*/

CGsdpQueueBase::CGsdpQueueBase()
	{
	}

void CGsdpQueueBase::ConstructL()
	{
	for (TInt i=0; i<10; i++)
		{
		TGsdpPacket* packet=new(ELeave) TGsdpPacket;
		iSlots.AddFirst(*packet);
		}
	}

CGsdpQueueBase::~CGsdpQueueBase()
	{
	TGsdpPacket* packet;
	for (packet=iSlots.First(); packet; packet=iSlots.First())
		{
		iSlots.Remove(*packet);
		delete packet;
		}
	for (packet=iPackets.First(); packet; packet=iPackets.First())
		{
		iPackets.Remove(*packet);
		delete packet;
		}
	}

// functions

TGsdpPacket* CGsdpQueueBase::AddPacket(TUint32 aGameProtocol, TUint32 aToPort, const TDesC8& aAddress, TUint32 aFromPort, const TDesC8& aData)
	/**
	   Queue a packet.

	   @param aAddress: the address to send to or from which this was received.
	*/
	{
	// get first free packet slot - drop packet if there isn't one
	TGsdpPacket* packet=iSlots.First();
	if (!packet)
		return 0;
	iSlots.Remove(*packet);
	// plug in values
	packet->iGameProtocol=aGameProtocol;
	packet->iToPort=aToPort;
	packet->iAddress=aAddress;
	packet->iFromPort=aFromPort;
	packet->iData=aData;
	// add to packet queue
	iPackets.AddLast(*packet);
	return packet;
	}

void CGsdpQueueBase::FreePacket(TGsdpPacket& aPacket)
	{
	iPackets.Remove(aPacket);
	iSlots.AddFirst(aPacket);
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -