mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
type change: use vector<uint8_t> rather than string in struct for
retrieving data from db.
This commit is contained in:
parent
e2f689765b
commit
cd2b83c9c5
4 changed files with 15 additions and 16 deletions
|
@ -839,7 +839,7 @@ CookieRef::handleEvents()
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CookieRef::send_with_length( const AddrInfo* addr, HostID dest,
|
CookieRef::send_with_length( const AddrInfo* addr, HostID dest,
|
||||||
const unsigned char* buf, int bufLen, bool cascade,
|
const uint8_t* buf, int bufLen, bool cascade,
|
||||||
uint32_t* packetIDP )
|
uint32_t* packetIDP )
|
||||||
{
|
{
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
|
@ -898,9 +898,8 @@ CookieRef::send_stored_messages( HostID dest, const AddrInfo* addr )
|
||||||
++iter ) {
|
++iter ) {
|
||||||
DBMgr::MsgInfo msg = *iter;
|
DBMgr::MsgInfo msg = *iter;
|
||||||
uint32_t packetID;
|
uint32_t packetID;
|
||||||
if ( !send_with_length( addr, dest,
|
if ( !send_with_length( addr, dest, msg.msg.data(),
|
||||||
(const unsigned char*)msg.msg.c_str(),
|
msg.msg.size(), true, &packetID ) ) {
|
||||||
msg.msg.length(), true, &packetID ) ) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( !UDPAckTrack::setOnAck( onMsgAcked, packetID, (void*)msg.msgID ) ) {
|
if ( !UDPAckTrack::setOnAck( onMsgAcked, packetID, (void*)msg.msgID ) ) {
|
||||||
|
|
|
@ -1006,14 +1006,15 @@ DBMgr::storedMessagesImpl( string test, vector<DBMgr::MsgInfo>& msgs )
|
||||||
int nTuples = PQntuples( result );
|
int nTuples = PQntuples( result );
|
||||||
for ( int ii = 0; ii < nTuples; ++ii ) {
|
for ( int ii = 0; ii < nTuples; ++ii ) {
|
||||||
int id = atoi( PQgetvalue( result, ii, 0 ) );
|
int id = atoi( PQgetvalue( result, ii, 0 ) );
|
||||||
size_t msglen = atoi( PQgetvalue( result, ii, 3 ) );
|
AddrInfo::ClientToken token = atoi( PQgetvalue( result, ii, 4 ) );
|
||||||
|
MsgInfo msg( id, token );
|
||||||
|
|
||||||
uint8_t buf[1024];
|
uint8_t buf[1024];
|
||||||
size_t buflen = sizeof(buf);
|
size_t buflen = sizeof(buf);
|
||||||
decodeMessage( result, m_useB64, ii, 1, 2, buf, &buflen );
|
decodeMessage( result, m_useB64, ii, 1, 2, buf, &buflen );
|
||||||
|
size_t msglen = atoi( PQgetvalue( result, ii, 3 ) );
|
||||||
assert( 0 == msglen || buflen == msglen );
|
assert( 0 == msglen || buflen == msglen );
|
||||||
string str( (char*)buf, buflen );
|
msg.msg.insert( msg.msg.end(), buf, &buf[buflen] );
|
||||||
AddrInfo::ClientToken token = atoi( PQgetvalue( result, ii, 4 ) );
|
|
||||||
MsgInfo msg( str, id, token );
|
|
||||||
msgs.push_back( msg );
|
msgs.push_back( msg );
|
||||||
}
|
}
|
||||||
PQclear( result );
|
PQclear( result );
|
||||||
|
|
|
@ -41,10 +41,10 @@ class DBMgr {
|
||||||
|
|
||||||
class MsgInfo {
|
class MsgInfo {
|
||||||
public:
|
public:
|
||||||
MsgInfo( string m, int id, AddrInfo::ClientToken tok ) {
|
MsgInfo( int id, AddrInfo::ClientToken tok ) {
|
||||||
msg = m; msgID = id; token = tok;
|
msgID = id; token = tok;
|
||||||
}
|
}
|
||||||
string msg;
|
vector<uint8_t> msg;
|
||||||
int msgID;
|
int msgID;
|
||||||
AddrInfo::ClientToken token;
|
AddrInfo::ClientToken token;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1156,8 +1156,8 @@ pushMsgs( vector<unsigned char>& out, DBMgr* dbmgr, const char* connName,
|
||||||
vector<DBMgr::MsgInfo>::const_iterator iter;
|
vector<DBMgr::MsgInfo>::const_iterator iter;
|
||||||
for ( iter = msgs.begin(); msgs.end() != iter; ++iter ) {
|
for ( iter = msgs.begin(); msgs.end() != iter; ++iter ) {
|
||||||
DBMgr::MsgInfo msg = *iter;
|
DBMgr::MsgInfo msg = *iter;
|
||||||
int len = msg.msg.length();
|
int len = msg.msg.size();
|
||||||
uint8_t* ptr = (uint8_t*)msg.msg.c_str();
|
uint8_t* ptr = msg.msg.data();
|
||||||
pushShort( out, len );
|
pushShort( out, len );
|
||||||
out.insert( out.end(), ptr, ptr + len );
|
out.insert( out.end(), ptr, ptr + len );
|
||||||
msgIDs.push_back( msg.msgID );
|
msgIDs.push_back( msg.msgID );
|
||||||
|
@ -1509,9 +1509,8 @@ retrieveMessages( DevID& devID, const AddrInfo* addr )
|
||||||
for ( iter = msgs.begin(); iter != msgs.end(); ++iter ) {
|
for ( iter = msgs.begin(); iter != msgs.end(); ++iter ) {
|
||||||
DBMgr::MsgInfo msg = *iter;
|
DBMgr::MsgInfo msg = *iter;
|
||||||
uint32_t packetID;
|
uint32_t packetID;
|
||||||
if ( !send_msg_via_udp( addr, msg.token,
|
if ( !send_msg_via_udp( addr, msg.token, msg.msg.data(),
|
||||||
(unsigned char*)msg.msg.c_str(),
|
msg.msg.size(), &packetID ) ) {
|
||||||
msg.msg.length(), &packetID ) ) {
|
|
||||||
logf( XW_LOGERROR, "%s: unable to send to devID %d",
|
logf( XW_LOGERROR, "%s: unable to send to devID %d",
|
||||||
__func__, devID.asRelayID() );
|
__func__, devID.asRelayID() );
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue