mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-27 07:58:49 +01:00
change format of reply to MSG_GET: include number of messages per
device to support fetching for more than one at once. This is meaningless for rq as written now but a device will want to do this.
This commit is contained in:
parent
481a533e58
commit
57ec020330
2 changed files with 23 additions and 13 deletions
|
@ -189,18 +189,28 @@ do_fetch( int sockfd, const char** connNames, int nConnNames )
|
|||
assert( count == nConnNames );
|
||||
fprintf( stderr, "got count: %d\n", count );
|
||||
|
||||
/* Now we have an array of <len><len bytes> pairs. Just write em as
|
||||
long as it makes sense.*/
|
||||
/* Now we have an array of <countPerDev> <len><len bytes> pairs. Just
|
||||
write em as long as it makes sense. countPerDev makes no sense as
|
||||
other than 1 unless the UI is changed so I don't have to write to
|
||||
STDOUT -- e.g. by passing in named pipes to correspond to each
|
||||
deviceid provided */
|
||||
|
||||
while ( bufp < end ) {
|
||||
unsigned short len;
|
||||
memcpy( &len, bufp, sizeof( len ) );
|
||||
len = ntohs( len ) + sizeof( len );
|
||||
if ( bufp + len > end ) {
|
||||
break;
|
||||
unsigned short countPerDev;
|
||||
memcpy( &countPerDev, bufp, sizeof( countPerDev ) );
|
||||
bufp += sizeof( countPerDev );
|
||||
countPerDev = ntohs( countPerDev );
|
||||
|
||||
while ( bufp < end && countPerDev-- > 0 ) {
|
||||
unsigned short len;
|
||||
memcpy( &len, bufp, sizeof( len ) );
|
||||
len = ntohs( len ) + sizeof( len );
|
||||
if ( bufp + len > end ) {
|
||||
break;
|
||||
}
|
||||
write( STDOUT_FILENO, bufp, len );
|
||||
bufp += len;
|
||||
}
|
||||
write( STDOUT_FILENO, bufp, len );
|
||||
bufp += len;
|
||||
}
|
||||
if ( bufp != end ) {
|
||||
fprintf( stderr, "error: message not internally as expected\n" );
|
||||
|
|
|
@ -77,8 +77,6 @@
|
|||
#include "dbmgr.h"
|
||||
|
||||
static int s_nSpawns = 0;
|
||||
#define MAX_PROXY_LEN 64
|
||||
#define MAX_PROXY_COUNT 48
|
||||
|
||||
void
|
||||
logf( XW_LogLevel level, const char* format, ... )
|
||||
|
@ -729,6 +727,7 @@ handleMsgsMsg( int sock, bool sendFull,
|
|||
char* in = (char*)bufp;
|
||||
DBMgr* dbmgr = DBMgr::Get();
|
||||
unsigned short count;
|
||||
/* This is wrong now */
|
||||
/* reply format: PRX_GET_MSGS case: <message len><n_msgs>[<len><msg>]*
|
||||
* PRX_HAS_MSGS case: <message len><n_msgs><count>*
|
||||
*/
|
||||
|
@ -747,11 +746,12 @@ handleMsgsMsg( int sock, bool sendFull,
|
|||
break;
|
||||
}
|
||||
|
||||
/* For each relayID, write the number of messages and then each
|
||||
message (in the getmsg case) */
|
||||
int msgCount = dbmgr->PendingMsgCount( connName, hid );
|
||||
pushShort( out, msgCount );
|
||||
if ( sendFull ) {
|
||||
pushMsgs( out, dbmgr, connName, hid, msgCount );
|
||||
} else {
|
||||
pushShort( out, msgCount );
|
||||
}
|
||||
|
||||
in = NULL;
|
||||
|
|
Loading…
Add table
Reference in a new issue