if can't send allcond to a device because it's not connected queue the

message to be sent next time it does.  And since the cookieID will
change and should be there already anyway, remove it.  (Should remove
the hostID too for the same reason.)
This commit is contained in:
Eric House 2010-10-22 19:02:52 -07:00
parent 6e843dec6c
commit 85d29cf560
2 changed files with 21 additions and 14 deletions

View file

@ -1236,10 +1236,6 @@ relayPreProcess( CommsCtxt* comms, XWStreamCtxt* stream, XWHostID* senderID )
|| comms->r.myHostID == srcID );
comms->r.myHostID = srcID;
XP_LOGF( "set hostid: %x", comms->r.myHostID );
cookieID = stream_getU16( stream );
XP_ASSERT( cookieID == comms->r.cookieID );
// comms->r.cookieID = stream_getU16( stream );
XP_LOGF( "set cookieID = %d", comms->r.cookieID );
#ifdef DEBUG
{

View file

@ -1034,7 +1034,6 @@ void
CookieRef::sendAllHere( bool initial )
{
unsigned char buf[1 + 1 /* hostID */
+ sizeof(CookieID)
+ 1 + MAX_CONNNAME_LEN];
unsigned char* bufp = buf;
@ -1043,8 +1042,6 @@ CookieRef::sendAllHere( bool initial )
*bufp++ = initial? XWRELAY_ALLHERE : XWRELAY_ALLBACK;
idLoc = bufp++; /* space for hostId, remembering address */
putNetShort( &bufp, GetCookieID() );
const char* connName = ConnName();
assert( !!connName && connName[0] );
int len = strlen( connName );
@ -1054,13 +1051,27 @@ CookieRef::sendAllHere( bool initial )
bufp += len;
ASSERT_LOCKED();
vector<HostRec>::iterator iter = m_sockets.begin();
while ( iter != m_sockets.end() ) {
logf( XW_LOGINFO, "%s: sending to hostid %d", __func__,
iter->m_hostID );
*idLoc = iter->m_hostID; /* write in this target's hostId */
send_with_length( iter->m_socket, buf, bufp-buf, true );
++iter;
/* Assuming destIds in range 1 .. nSought, for each find if it's here and
if it is try sending to it. If fail, or it's not here, store the
message for it. Would be better if could look up rather than run
through the vector each time. */
HostID dest;
for ( dest = 1; dest <= m_nPlayersHere; ++dest ) {
bool sent = false;
*idLoc = dest; /* write in this target's hostId */
vector<HostRec>::iterator iter;
for ( iter = m_sockets.begin(); iter != m_sockets.end(); ++iter ) {
if ( iter->m_hostID == dest ) {
sent = send_with_length( iter->m_socket, buf, bufp-buf,
true );
break;
}
}
if ( !sent ) {
store_message( dest, buf, bufp-buf );
}
}
} /* sendAllHere */