mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-02 06:20:14 +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
|
||||
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 )
|
||||
{
|
||||
bool failed = false;
|
||||
|
@ -898,9 +898,8 @@ CookieRef::send_stored_messages( HostID dest, const AddrInfo* addr )
|
|||
++iter ) {
|
||||
DBMgr::MsgInfo msg = *iter;
|
||||
uint32_t packetID;
|
||||
if ( !send_with_length( addr, dest,
|
||||
(const unsigned char*)msg.msg.c_str(),
|
||||
msg.msg.length(), true, &packetID ) ) {
|
||||
if ( !send_with_length( addr, dest, msg.msg.data(),
|
||||
msg.msg.size(), true, &packetID ) ) {
|
||||
break;
|
||||
}
|
||||
if ( !UDPAckTrack::setOnAck( onMsgAcked, packetID, (void*)msg.msgID ) ) {
|
||||
|
|
|
@ -1006,14 +1006,15 @@ DBMgr::storedMessagesImpl( string test, vector<DBMgr::MsgInfo>& msgs )
|
|||
int nTuples = PQntuples( result );
|
||||
for ( int ii = 0; ii < nTuples; ++ii ) {
|
||||
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];
|
||||
size_t buflen = sizeof(buf);
|
||||
decodeMessage( result, m_useB64, ii, 1, 2, buf, &buflen );
|
||||
size_t msglen = atoi( PQgetvalue( result, ii, 3 ) );
|
||||
assert( 0 == msglen || buflen == msglen );
|
||||
string str( (char*)buf, buflen );
|
||||
AddrInfo::ClientToken token = atoi( PQgetvalue( result, ii, 4 ) );
|
||||
MsgInfo msg( str, id, token );
|
||||
msg.msg.insert( msg.msg.end(), buf, &buf[buflen] );
|
||||
msgs.push_back( msg );
|
||||
}
|
||||
PQclear( result );
|
||||
|
|
|
@ -41,10 +41,10 @@ class DBMgr {
|
|||
|
||||
class MsgInfo {
|
||||
public:
|
||||
MsgInfo( string m, int id, AddrInfo::ClientToken tok ) {
|
||||
msg = m; msgID = id; token = tok;
|
||||
MsgInfo( int id, AddrInfo::ClientToken tok ) {
|
||||
msgID = id; token = tok;
|
||||
}
|
||||
string msg;
|
||||
vector<uint8_t> msg;
|
||||
int msgID;
|
||||
AddrInfo::ClientToken token;
|
||||
};
|
||||
|
|
|
@ -1156,8 +1156,8 @@ pushMsgs( vector<unsigned char>& out, DBMgr* dbmgr, const char* connName,
|
|||
vector<DBMgr::MsgInfo>::const_iterator iter;
|
||||
for ( iter = msgs.begin(); msgs.end() != iter; ++iter ) {
|
||||
DBMgr::MsgInfo msg = *iter;
|
||||
int len = msg.msg.length();
|
||||
uint8_t* ptr = (uint8_t*)msg.msg.c_str();
|
||||
int len = msg.msg.size();
|
||||
uint8_t* ptr = msg.msg.data();
|
||||
pushShort( out, len );
|
||||
out.insert( out.end(), ptr, ptr + len );
|
||||
msgIDs.push_back( msg.msgID );
|
||||
|
@ -1509,9 +1509,8 @@ retrieveMessages( DevID& devID, const AddrInfo* addr )
|
|||
for ( iter = msgs.begin(); iter != msgs.end(); ++iter ) {
|
||||
DBMgr::MsgInfo msg = *iter;
|
||||
uint32_t packetID;
|
||||
if ( !send_msg_via_udp( addr, msg.token,
|
||||
(unsigned char*)msg.msg.c_str(),
|
||||
msg.msg.length(), &packetID ) ) {
|
||||
if ( !send_msg_via_udp( addr, msg.token, msg.msg.data(),
|
||||
msg.msg.size(), &packetID ) ) {
|
||||
logf( XW_LOGERROR, "%s: unable to send to devID %d",
|
||||
__func__, devID.asRelayID() );
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue