mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
relay tracks variantCode int, not string
This commit is contained in:
parent
6bc65476d0
commit
8456b9fd76
7 changed files with 36 additions and 33 deletions
|
@ -1031,7 +1031,7 @@ public class RelayService extends XWJIService
|
|||
writeVLIString( out, BuildConfig.GIT_REV );
|
||||
writeVLIString( out, Build.MODEL );
|
||||
writeVLIString( out, Build.VERSION.RELEASE );
|
||||
writeVLIString( out, BuildConfig.VARIANT_NAME );
|
||||
writeShort( out, BuildConfig.VARIANT_CODE );
|
||||
|
||||
postPacket( bas, XWRelayReg.XWPDEV_REG, timestamp );
|
||||
s_regStartTime = now;
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#define MAX_MOVE_CHECK_MS ((XP_U16)(1000 * 60 * 60 * 24))
|
||||
#define RELAY_API_PROTO "http"
|
||||
|
||||
#define CLIENT_VARIANT_CODE 1000
|
||||
|
||||
typedef struct _RelayConStorage {
|
||||
pthread_t mainThread;
|
||||
guint moveCheckerID;
|
||||
|
@ -305,7 +307,7 @@ relaycon_reg( LaunchParams* params, const XP_UCHAR* rDevID,
|
|||
indx += addVLIStr( &tmpbuf[indx], sizeof(tmpbuf) - indx, SVN_REV );
|
||||
indx += addVLIStr( &tmpbuf[indx], sizeof(tmpbuf) - indx, "linux box" );
|
||||
indx += addVLIStr( &tmpbuf[indx], sizeof(tmpbuf) - indx, "linux version" );
|
||||
indx += addVLIStr( &tmpbuf[indx], sizeof(tmpbuf) - indx, "linux variant" );
|
||||
indx += writeShort( &tmpbuf[indx], sizeof(tmpbuf) - indx, CLIENT_VARIANT_CODE );
|
||||
|
||||
sendIt( storage, tmpbuf, indx, 0.5 );
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ DBMgr::FindRelayIDFor( const char* connName, HostID hid,
|
|||
if ( found ) {
|
||||
devID = (DevIDRelay)strtoul( PQgetvalue( result, 0, 0 ), NULL, 10 );
|
||||
*devIDP = devID;
|
||||
ReregisterDevice( devID, host, NULL, 0, NULL, NULL, NULL );
|
||||
ReregisterDevice( devID, host, NULL, 0, NULL, NULL, 0);
|
||||
}
|
||||
PQclear( result );
|
||||
if ( !found ) {
|
||||
|
@ -390,7 +390,7 @@ DBMgr::AllDevsAckd( const char* const connName )
|
|||
DevIDRelay
|
||||
DBMgr::RegisterDevice( const DevID* host, int clientVersion,
|
||||
const char* const desc, const char* const model,
|
||||
const char* const osVers, const char* const variant )
|
||||
const char* const osVers, unsigned short variantCode )
|
||||
{
|
||||
DevIDRelay devID;
|
||||
assert( host->m_devIDType != ID_TYPE_NONE );
|
||||
|
@ -418,7 +418,7 @@ DBMgr::RegisterDevice( const DevID* host, int clientVersion,
|
|||
|
||||
QueryBuilder qb;
|
||||
qb.appendQueryf( "INSERT INTO " DEVICES_TABLE " (id, devTypes[1],"
|
||||
" devids[1], clntVers, versdesc, model, osvers, variant)"
|
||||
" devids[1], clntVers, versdesc, model, osvers, variantCode)"
|
||||
" VALUES($$, $$, $$, $$, $$, $$, $$, $$)" )
|
||||
|
||||
.appendParam( devID )
|
||||
|
@ -428,7 +428,7 @@ DBMgr::RegisterDevice( const DevID* host, int clientVersion,
|
|||
.appendParam( desc )
|
||||
.appendParam( model )
|
||||
.appendParam( osVers )
|
||||
.appendParam( variant )
|
||||
.appendParam( variantCode )
|
||||
.finish();
|
||||
|
||||
success = execParams( qb );
|
||||
|
@ -440,14 +440,14 @@ DBMgr::RegisterDevice( const DevID* host, int clientVersion,
|
|||
DevIDRelay
|
||||
DBMgr::RegisterDevice( const DevID* host )
|
||||
{
|
||||
return RegisterDevice( host, 0, NULL, NULL, NULL, NULL );
|
||||
return RegisterDevice( host, 0, NULL, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
DBMgr::ReregisterDevice( DevIDRelay relayID, const DevID* host,
|
||||
const char* const desc, int clientVersion,
|
||||
const char* const model, const char* const osVers,
|
||||
const char* const variant )
|
||||
unsigned short variantCode )
|
||||
{
|
||||
QueryBuilder qb;
|
||||
qb.appendQueryf( "UPDATE " DEVICES_TABLE " SET "
|
||||
|
@ -456,7 +456,7 @@ DBMgr::ReregisterDevice( DevIDRelay relayID, const DevID* host,
|
|||
.appendParam( host->m_devIDType )
|
||||
.appendParam( host->m_devIDString.c_str() );
|
||||
|
||||
formatUpdate( qb, true, desc, clientVersion, model, osVers, variant,
|
||||
formatUpdate( qb, true, desc, clientVersion, model, osVers, variantCode,
|
||||
relayID );
|
||||
qb.finish();
|
||||
execParams( qb );
|
||||
|
@ -466,7 +466,7 @@ DBMgr::ReregisterDevice( DevIDRelay relayID, const DevID* host,
|
|||
bool
|
||||
DBMgr::UpdateDevice( DevIDRelay relayID, const char* const desc,
|
||||
int clientVersion, const char* const model,
|
||||
const char* const osVers, const char* const variant,
|
||||
const char* const osVers, unsigned short variantCode,
|
||||
bool check )
|
||||
{
|
||||
bool exists = !check;
|
||||
|
@ -480,7 +480,7 @@ DBMgr::UpdateDevice( DevIDRelay relayID, const char* const desc,
|
|||
QueryBuilder qb;
|
||||
qb.appendQueryf( "UPDATE " DEVICES_TABLE " SET " );
|
||||
formatUpdate( qb, false, desc, clientVersion, model, osVers,
|
||||
variant, relayID );
|
||||
variantCode, relayID );
|
||||
qb.finish();
|
||||
execParams( qb );
|
||||
}
|
||||
|
@ -490,14 +490,14 @@ DBMgr::UpdateDevice( DevIDRelay relayID, const char* const desc,
|
|||
bool
|
||||
DBMgr::UpdateDevice( DevIDRelay relayID )
|
||||
{
|
||||
return UpdateDevice( relayID, NULL, 0, NULL, NULL, NULL, false );
|
||||
return UpdateDevice( relayID, NULL, 0, NULL, NULL, 0, false );
|
||||
}
|
||||
|
||||
void
|
||||
DBMgr::formatUpdate( QueryBuilder& qb,
|
||||
bool append, const char* const desc,
|
||||
int clientVersion, const char* const model,
|
||||
const char* const osVers, const char* const variant,
|
||||
const char* const osVers, unsigned short variantCode,
|
||||
DevIDRelay relayID )
|
||||
{
|
||||
qb.appendQueryf( "mtimes[1]='now'" );
|
||||
|
@ -516,10 +516,8 @@ DBMgr::formatUpdate( QueryBuilder& qb,
|
|||
qb.appendQueryf( ", osvers=$$" )
|
||||
.appendParam( osVers );
|
||||
}
|
||||
if ( NULL != variant && '\0' != variant[0] ) {
|
||||
qb.appendQueryf( ", variant=$$" )
|
||||
.appendParam( variant );
|
||||
}
|
||||
qb.appendQueryf( ", variantCode=$$" ).appendParam( variantCode );
|
||||
|
||||
qb.appendQueryf( " WHERE id = $$" )
|
||||
.appendParam( relayID );
|
||||
}
|
||||
|
|
|
@ -101,14 +101,15 @@ class DBMgr {
|
|||
DevIDRelay RegisterDevice( const DevID* host );
|
||||
DevIDRelay RegisterDevice( const DevID* host, int clientVersion,
|
||||
const char* const desc, const char* const model,
|
||||
const char* const osVers, const char* const variant );
|
||||
const char* const osVers,
|
||||
unsigned short variantCode );
|
||||
void ReregisterDevice( DevIDRelay relayID, const DevID* host,
|
||||
const char* const desc, int clientVersion,
|
||||
const char* const model, const char* const osVers,
|
||||
const char* const variant );
|
||||
unsigned short variantCode );
|
||||
bool UpdateDevice( DevIDRelay relayID, const char* const desc,
|
||||
int clientVersion, const char* const model,
|
||||
const char* const osVers, const char* const variant,
|
||||
const char* const osVers, unsigned short variantCode,
|
||||
bool check );
|
||||
|
||||
HostID AddToGame( const char* const connName, HostID curID, int clientVersion,
|
||||
|
@ -176,10 +177,9 @@ class DBMgr {
|
|||
bool UpdateDevice( DevIDRelay relayID );
|
||||
void formatUpdate( QueryBuilder& qb, bool append, const char* const desc,
|
||||
int clientVersion, const char* const model,
|
||||
const char* const osVers, const char* const variant,
|
||||
const char* const osVers, unsigned short variantCode,
|
||||
DevIDRelay relayID );
|
||||
|
||||
|
||||
PGconn* getThreadConn( void );
|
||||
void clearThreadConn();
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ echo "SELECT id,connName,hid as h,token,ctime,stime,devid as dest,msg64 "\
|
|||
| psql xwgames
|
||||
|
||||
# Devices
|
||||
LINE="SELECT id, model, variant as var, osvers, array_length(mtimes, 1) as mcnt, mtimes[1] as mtime, array_length(devTypes, 1) as dcnt, devTypes as dTyps, devids[1] as devid_1 FROM devices "
|
||||
LINE="SELECT id, model, variantCode as var, osvers, array_length(mtimes, 1) as mcnt, mtimes[1] as mtime, array_length(devTypes, 1) as dcnt, devTypes as dTyps, devids[1] as devid_1 FROM devices "
|
||||
if [ -n "$FILTER_DEVS" ]; then
|
||||
LINE="${LINE} WHERE id IN (select UNNEST(devids) FROM games $QUERY)"
|
||||
fi
|
||||
|
|
|
@ -1599,7 +1599,7 @@ static void
|
|||
registerDevice( const string& relayIDStr, const DevID* devID,
|
||||
const AddrInfo* addr, int clientVers, const string& devDesc,
|
||||
const string& model, const string& osVers,
|
||||
const string& variant )
|
||||
unsigned short variantCode )
|
||||
{
|
||||
DevIDRelay relayID = DBMgr::DEVID_NONE;
|
||||
DBMgr* dbMgr = DBMgr::Get();
|
||||
|
@ -1611,16 +1611,16 @@ registerDevice( const string& relayIDStr, const DevID* devID,
|
|||
|
||||
if ( DBMgr::DEVID_NONE == relayID ) { // new device
|
||||
relayID = dbMgr->RegisterDevice( devID, clientVers, devDesc.c_str(),
|
||||
model.c_str(), osVers.c_str(), variant.c_str() );
|
||||
model.c_str(), osVers.c_str(), variantCode );
|
||||
} else if ( ID_TYPE_RELAY < devID->m_devIDType ) { // re-registering
|
||||
dbMgr->ReregisterDevice( relayID, devID, devDesc.c_str(), clientVers,
|
||||
model.c_str(), osVers.c_str(), variant.c_str() );
|
||||
model.c_str(), osVers.c_str(), variantCode );
|
||||
checkMsgs = true;
|
||||
} else {
|
||||
// No new information; just update the time
|
||||
checkMsgs = dbMgr->UpdateDevice( relayID, devDesc.c_str(), clientVers,
|
||||
model.c_str(), osVers.c_str(), variant.c_str(),
|
||||
true );
|
||||
model.c_str(), osVers.c_str(),
|
||||
variantCode, true );
|
||||
if ( !checkMsgs ) {
|
||||
uint8_t buf[32];
|
||||
int indx = addRegID( &buf[0], relayID );
|
||||
|
@ -1772,13 +1772,16 @@ handle_udp_packet( PacketThreadClosure* ptc )
|
|||
if ( 3 >= clientVers ) {
|
||||
checkAllAscii( model, "bad model" );
|
||||
}
|
||||
string variant;
|
||||
if ( getVLIString( &ptr, end, variant ) ) {
|
||||
logf( XW_LOGINFO, "%s(): got variant %s", __func__, variant.c_str() );
|
||||
|
||||
unsigned short variantCode = 0;
|
||||
if ( getNetShort( &ptr, end, &variantCode ) ) {
|
||||
logf( XW_LOGINFO, "%s(): got variantCode %d", __func__,
|
||||
variantCode );
|
||||
}
|
||||
|
||||
registerDevice( relayID, &devID, ptc->addr(),
|
||||
clientVers, devDesc, model, osVers, variant );
|
||||
clientVers, devDesc, model, osVers,
|
||||
variantCode );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ id INTEGER UNIQUE PRIMARY KEY
|
|||
,versDesc TEXT
|
||||
,model TEXT
|
||||
,osvers TEXT
|
||||
,variant TEXT
|
||||
,variantCode INTEGER DEFAULT 0
|
||||
,ctime TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
,mtimes TIMESTAMP[]
|
||||
,unreg BOOLEAN DEFAULT FALSE
|
||||
|
|
Loading…
Reference in a new issue