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 );
comms->r.myHostID = srcID; comms->r.myHostID = srcID;
XP_LOGF( "set hostid: %x", comms->r.myHostID ); 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 #ifdef DEBUG
{ {

View file

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