diff --git a/xwords4/relay/cref.cpp b/xwords4/relay/cref.cpp index c9b9f745e..3a338cc28 100644 --- a/xwords4/relay/cref.cpp +++ b/xwords4/relay/cref.cpp @@ -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 ) ) { diff --git a/xwords4/relay/dbmgr.cpp b/xwords4/relay/dbmgr.cpp index e33e760a6..21c9a26c7 100644 --- a/xwords4/relay/dbmgr.cpp +++ b/xwords4/relay/dbmgr.cpp @@ -1006,14 +1006,15 @@ DBMgr::storedMessagesImpl( string test, vector& 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 ); diff --git a/xwords4/relay/dbmgr.h b/xwords4/relay/dbmgr.h index 7dfcaf001..bccb5c8d6 100644 --- a/xwords4/relay/dbmgr.h +++ b/xwords4/relay/dbmgr.h @@ -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 msg; int msgID; AddrInfo::ClientToken token; }; diff --git a/xwords4/relay/xwrelay.cpp b/xwords4/relay/xwrelay.cpp index 8f2097f9a..676db31a5 100644 --- a/xwords4/relay/xwrelay.cpp +++ b/xwords4/relay/xwrelay.cpp @@ -1156,8 +1156,8 @@ pushMsgs( vector& out, DBMgr* dbmgr, const char* connName, vector::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;