mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-17 18:12:01 +01:00
keep queue of incoming packets since new ones arrive before old can be
processed. With this fix a complete robot-vs-robot game works between 9300 and gtk version over relay.
This commit is contained in:
parent
1f3d94998f
commit
5eba6f5511
2 changed files with 13 additions and 6 deletions
|
@ -201,7 +201,7 @@ class CXWordsAppView : public CCoeControl
|
|||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
CSendSocket* iSendSock;
|
||||
TBuf8<MAX_MSG_LEN> iNewPacket;
|
||||
CDesC8ArrayFlat* iNewPacketQueue;
|
||||
#endif
|
||||
|
||||
MPSLOT
|
||||
|
|
|
@ -103,6 +103,7 @@ CXWordsAppView::~CXWordsAppView()
|
|||
delete iGamesMgr;
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
delete iSendSock;
|
||||
delete iNewPacketQueue;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -131,6 +132,7 @@ void CXWordsAppView::ConstructL(const TRect& aRect)
|
|||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
iSendSock = CSendSocket::NewL( PacketReceived, (void*)this );
|
||||
XP_LOGF( "iSendSock created" );
|
||||
iNewPacketQueue = new (ELeave)CDesC8ArrayFlat(2);
|
||||
#endif
|
||||
|
||||
// Set the control's border
|
||||
|
@ -869,9 +871,11 @@ CXWordsAppView::TimerCallback( TAny* aPtr )
|
|||
|
||||
XWStreamCtxt* stream = me->MakeSimpleStream( NULL );
|
||||
|
||||
stream_putBytes( stream, (void*)me->iNewPacket.Ptr(),
|
||||
me->iNewPacket.Length() );
|
||||
me->iNewPacket.SetLength(0);
|
||||
TPtrC8 packet = (*me->iNewPacketQueue)[0];
|
||||
stream_putBytes( stream, (void*)packet.Ptr(), packet.Length() );
|
||||
me->iNewPacketQueue->Delete(0);
|
||||
XP_LOGF( "pulling packet off head of queue; there are %d left",
|
||||
me->iNewPacketQueue->Count() );
|
||||
|
||||
CommsAddrRec addr;
|
||||
addr.conType = COMMS_CONN_RELAY;
|
||||
|
@ -1279,8 +1283,11 @@ CXWordsAppView::DrawGameName() const
|
|||
CXWordsAppView::PacketReceived( const TDesC8* aBuf, void* aClosure )
|
||||
{
|
||||
CXWordsAppView* me = (CXWordsAppView*)aClosure;
|
||||
XP_ASSERT( me->iNewPacket.Length() == 0 );
|
||||
me->iNewPacket.Copy( *aBuf );
|
||||
|
||||
TInt count = me->iNewPacketQueue->Count();
|
||||
me->iNewPacketQueue->InsertL( count, *aBuf );
|
||||
XP_LOGF( "inserted packet: now number %d", count );
|
||||
|
||||
me->StartIdleTimer( EProcessPacket );
|
||||
} /* CXWordsAppView::PacketReceived */
|
||||
|
||||
|
|
Loading…
Reference in a new issue