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

📄 gdpqueue.cpp

📁 Symbian mobile os C++ GSDP编程
💻 CPP
字号:
// gdpqueue.cpp
//
// Copyright (c) 2000 Symbian Ltd.  All rights reserved.
//

#include "gdpqueue.h"
#include <ImplementationProxy.h>
#include <ecom.h>

// game datagram protocol - loopback with queuing

class CSendTimer : public CTimer
	{
public:
	static CSendTimer* NewL(CGdpQueue* aQ);
			
	CSendTimer(CGdpQueue* aQ) : CTimer(0), iQ(aQ) {CActiveScheduler::Add(this);};
	void RunL() {iQ->FinishSend();};
	CGdpQueue* iQ;
	};

CSendTimer* CSendTimer::NewL(CGdpQueue* aQ)
	{
	CSendTimer* self = new (ELeave) CSendTimer(aQ);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
	}

CGdpQueue::CGdpQueue()
	{
	}

CGdpQueue::~CGdpQueue()
	{
	delete iTimer;
	REComSession::DestroyedImplementation(iDtor_ID_Key);
	}

void CGdpQueue::OpenL(MGdpPacketHandler* aHandler) // start up, and set handler for packets received
	{
	iHandler=aHandler;
	}

void CGdpQueue::SendL(const TDesC8& aToAddress, const TDesC8& aData) // send packet
	{
	iAddress = aToAddress;
	iData = aData;
	iTimer->After(1000000);  // 1sec
	}

void CGdpQueue::FinishSend()
	{
	iHandler->GdpHandleL(iAddress, iData); // loop back to handler
	}

TInt CGdpQueue::ReceiveAll() // do a pull if necessary
	{
	return KErrNone;
	}

TInt CGdpQueue::GetMaxPacketLength() const
	{
	return 255;
	}

TInt CGdpQueue::IsNetworked() const
	{
	return EFalse;
	}

void CGdpQueue::ConstructL()
	{
	iTimer = CSendTimer::NewL(this);
	}

CGdpSession* CGdpQueue::NewL()
	{
	CGdpQueue* self=new (ELeave) CGdpQueue();
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
	}

// Define the interface UIDs
const TImplementationProxy ImplementationTable[] =
    {
    {{0x101f8b5a}, CGdpQueue::NewL},
    };

EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
    {
    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);

    return ImplementationTable;
    }

TInt E32Dll(TDllReason)
	{
	return KErrNone;
	}

⌨️ 快捷键说明

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