03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The receive queue is a list of datagrams (referred to as 'packets' in its API) waiting to be<br />

received by clients. Packets are added to the list by the Receive() function. A packet just<br />

added to the list is offered to all sessions to see whether it can be received. When a session<br />

changes its settings or issues a receive, it checks the receive queue using<br />

CheckPackets() to see if there are any packets waiting for that session. By this means, a<br />

packet is delivered to a session as soon as possible.<br />

Here is the definition:<br />

class CGsdpReceiveQueue : public CGsdpQueueBase<br />

{<br />

public:<br />

enum TReceiveCheck { EAllowZero, EDontAllowZero };<br />

public:<br />

// construct<br />

static CGsdpReceiveQueue* NewL(CGsdpServer& aServer);<br />

// functions<br />

void Receive(TUint32 aGameProtocol, TUint32 aToPort, const<br />

TDesC8&<br />

aFromAddress, TUint32 aFromPort, const TDesC8& aData);<br />

void CheckPackets(CGsdpSession* aSession);<br />

private:<br />

CGsdpReceiveQueue(CGsdpServer& aServer);<br />

private:<br />

CGsdpServer& iServer;<br />

};<br />

On construction, CGsdpQueueBase creates 10 blank packets and adds them to the iSlots<br />

queue. When a packet is received, the following processing takes place:<br />

void CGsdpReceiveQueue::Receive(TUint32 aGameProtocol, TUint32<br />

aToPort,<br />

const TDesC8& aFromAddress, TUint32 aFromPort, const TDesC8&<br />

aData)<br />

{<br />

TGsdpPacket* packet=AddPacket(aGameProtocol, aToPort,<br />

aFromAddress,<br />

aFromPort, aData);<br />

if (!packet)<br />

return;<br />

CGsdpSession* session=iServer.SessionForPacket(*packet);<br />

if (!session)<br />

return;<br />

session->ReceivePacket(*packet);<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!