Merge branch 'relay_proxy' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into relay_proxy

This commit is contained in:
eehouse@eehouse.org 2010-10-23 19:50:11 -07:00 committed by Andy2
commit 24fae0f53b
3 changed files with 22 additions and 15 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

@ -1097,7 +1097,7 @@ main( int argc, char** argv )
} else if ( conType == COMMS_CONN_RELAY ) {
mainParams.connInfo.relay.relayName = hostName;
if ( NULL == portNum ) {
portNum = "10999";
portNum = "10997";
}
mainParams.connInfo.relay.defaultSendPort = atoi( portNum );
#endif

View file

@ -1036,7 +1036,6 @@ void
CookieRef::sendAllHere( bool initial )
{
unsigned char buf[1 + 1 /* hostID */
+ sizeof(CookieID)
+ 1 + MAX_CONNNAME_LEN];
unsigned char* bufp = buf;
@ -1045,8 +1044,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 );
@ -1056,13 +1053,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 */