mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
when a message sent via udp from cref isn't acked, add it to stored
messages so gcm loop can pick it up.
This commit is contained in:
parent
9640d0c5f9
commit
c1f94681bb
2 changed files with 32 additions and 1 deletions
|
@ -1188,6 +1188,25 @@ CookieRef::sendAnyStored( const CRefEvent* evt )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct _StoreData {
|
||||||
|
string connName;
|
||||||
|
HostID dest;
|
||||||
|
uint8_t* buf;
|
||||||
|
int buflen;
|
||||||
|
} StoreData;
|
||||||
|
|
||||||
|
void
|
||||||
|
CookieRef::storeNoAck( bool acked, uint32_t packetID, void* data )
|
||||||
|
{
|
||||||
|
StoreData* sdata = (StoreData*)data;
|
||||||
|
if ( !acked ) {
|
||||||
|
DBMgr::Get()->StoreMessage( sdata->connName.c_str(), sdata->dest,
|
||||||
|
sdata->buf, sdata->buflen );
|
||||||
|
}
|
||||||
|
free( sdata->buf );
|
||||||
|
free( sdata );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CookieRef::forward_or_store( const CRefEvent* evt )
|
CookieRef::forward_or_store( const CRefEvent* evt )
|
||||||
{
|
{
|
||||||
|
@ -1214,9 +1233,19 @@ CookieRef::forward_or_store( const CRefEvent* evt )
|
||||||
usleep( m_delayMicros );
|
usleep( m_delayMicros );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t packetID = 0;
|
||||||
if ( (NULL == destAddr)
|
if ( (NULL == destAddr)
|
||||||
|| !send_with_length( destAddr, dest, buf, buflen, true ) ) {
|
|| !send_with_length( destAddr, dest, buf, buflen, true,
|
||||||
|
&packetID ) ) {
|
||||||
store_message( dest, buf, buflen );
|
store_message( dest, buf, buflen );
|
||||||
|
} else if ( 0 != packetID ) { // sent via UDP
|
||||||
|
StoreData* data = new StoreData;
|
||||||
|
data->connName = m_connName;
|
||||||
|
data->dest = dest;
|
||||||
|
data->buf = (uint8_t*)malloc( buflen );
|
||||||
|
memcpy( data->buf, buf, buflen );
|
||||||
|
data->buflen = buflen;
|
||||||
|
UDPAckTrack::setOnAck( storeNoAck, packetID, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
// If recipient GAME isn't connected, see if owner device is and can
|
// If recipient GAME isn't connected, see if owner device is and can
|
||||||
|
|
|
@ -250,6 +250,8 @@ class CookieRef {
|
||||||
void setAckTimer( HostID hid );
|
void setAckTimer( HostID hid );
|
||||||
void cancelAckTimer( HostID hid );
|
void cancelAckTimer( HostID hid );
|
||||||
|
|
||||||
|
static void storeNoAck( bool acked, uint32_t packetID, void* data );
|
||||||
|
|
||||||
void forward_or_store( const CRefEvent* evt );
|
void forward_or_store( const CRefEvent* evt );
|
||||||
void send_denied( const CRefEvent* evt, XWREASON why );
|
void send_denied( const CRefEvent* evt, XWREASON why );
|
||||||
void send_trytell( const CRefEvent* evt );
|
void send_trytell( const CRefEvent* evt );
|
||||||
|
|
Loading…
Add table
Reference in a new issue