mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-06 21:58:57 -04:00
Suppressed echoes in chat lobbies by:
- adding a time stamp to lobby events (new item tag) - controllign time stamp of lobby msg and event: drop packets if time is older than cache duration. - moved connexion challenge code to lobby management loop - added new type of lobby invite to handle connexion challenges and avoid false invitations in the GUI New lobby event format is not backward compatible -> "peer typing" and "peer joined/left" will need the new version. Messages are still compatible) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4859 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6de8541a4e
commit
c3be19227d
5 changed files with 125 additions and 91 deletions
|
@ -46,7 +46,7 @@ std::ostream& RsChatMsgItem::print(std::ostream &out, uint16_t indent)
|
|||
out << "QblogMs " << chatFlags << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "sendTime: " << sendTime << std::endl;
|
||||
out << "sendTime: " << sendTime << " (" << time(NULL)-sendTime << " secs ago)" << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
|
||||
|
@ -97,6 +97,7 @@ std::ostream& RsChatLobbyEventItem::print(std::ostream &out, uint16_t indent)
|
|||
RsChatLobbyBouncingObject::print(out,indent) ;
|
||||
printIndent(out, indent); out << "Event type : " << event_type << std::endl;
|
||||
printIndent(out, indent); out << "String param: " << string1 << std::endl;
|
||||
printIndent(out, indent); out << "Send time: " << sendTime << " (" << time(NULL)-sendTime << " secs ago)" << std::endl;
|
||||
printRsItemEnd(out, "RsChatLobbyEventItem", indent);
|
||||
return out;
|
||||
}
|
||||
|
@ -148,7 +149,7 @@ std::ostream& RsPrivateChatMsgConfigItem::print(std::ostream &out, uint16_t inde
|
|||
out << "QblogMs " << configFlags << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "sendTime: " << sendTime << std::endl;
|
||||
out << "sendTime: " << sendTime << " (" << time(NULL)-sendTime << " secs ago)" << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
|
||||
|
@ -271,6 +272,7 @@ uint32_t RsChatLobbyEventItem::serial_size()
|
|||
s += RsChatLobbyBouncingObject::serial_size() ;
|
||||
s += 1 ; // event_type
|
||||
s += GetTlvStringSize(string1) ; // string1
|
||||
s += 4 ; // send time
|
||||
|
||||
return s ;
|
||||
}
|
||||
|
@ -506,6 +508,7 @@ bool RsChatLobbyEventItem::serialise(void *data, uint32_t& pktsize)
|
|||
ok &= RsChatLobbyBouncingObject::serialise(data,tlvsize,offset) ; // first, serialize parent
|
||||
ok &= setRawUInt8(data, tlvsize, &offset, event_type);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, string1);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, sendTime);
|
||||
|
||||
pktsize = tlvsize ;
|
||||
|
||||
|
@ -752,7 +755,7 @@ RsChatMsgItem::RsChatMsgItem(void *data,uint32_t /*size*/,uint8_t subtype)
|
|||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "Building new chat msg item." << std::endl ;
|
||||
#endif
|
||||
if (getRsItemSubType(getRsItemId(data)) == subtype && offset != rssize)
|
||||
if (getRsItemSubType(getRsItemId(data)) == RS_PKT_SUBTYPE_DEFAULT && offset != rssize)
|
||||
std::cerr << "Size error while deserializing." << std::endl ;
|
||||
if (!ok)
|
||||
std::cerr << "Unknown error while deserializing." << std::endl ;
|
||||
|
@ -841,6 +844,7 @@ RsChatLobbyEventItem::RsChatLobbyEventItem(void *data,uint32_t /*size*/)
|
|||
|
||||
ok &= getRawUInt8(data, rssize, &offset, &event_type);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, string1);
|
||||
ok &= getRawUInt32(data, rssize, &offset, &sendTime);
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "Building new chat lobby status item." << std::endl ;
|
||||
|
|
|
@ -56,11 +56,12 @@ const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE_DEPREC = 0x07 ; // don't use ! De
|
|||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_ACCEPT = 0x08 ;
|
||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_CHALLENGE = 0x09 ;
|
||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_UNSUBSCRIBE = 0x0A ;
|
||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_EVENT = 0x0B ;
|
||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_EVENT_DEPREC = 0x0B ; // don't use ! Deprecated
|
||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_MSG = 0x0C ;
|
||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_LIST_REQUEST = 0x0D ;
|
||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_LIST = 0x0E ;
|
||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_INVITE = 0x0F ;
|
||||
const uint8_t RS_PKT_SUBTYPE_CHAT_LOBBY_EVENT = 0x10 ;
|
||||
|
||||
// for defining tags themselves and msg tags
|
||||
const uint8_t RS_PKT_SUBTYPE_MSG_TAG_TYPE = 0x03;
|
||||
|
@ -167,6 +168,7 @@ class RsChatLobbyEventItem: public RsChatItem, public RsChatLobbyBouncingObject
|
|||
//
|
||||
uint8_t event_type ; // used for defining the type of event.
|
||||
std::string string1; // used for any string
|
||||
uint32_t sendTime; // used to check for old looping messages
|
||||
};
|
||||
|
||||
class RsChatLobbyListRequestItem: public RsChatItem
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue