mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
patch "Fix_ChatLobbyAutoSubscribe_6951.diff" from Phenom. Fixes request for existing lobbies when no lobby ihas been found yet. Code beautification
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6971 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5c52890ad5
commit
ee4985c935
@ -63,7 +63,7 @@ static const time_t MAX_KEEP_PUBLIC_LOBBY_RECORD = 60 ; // keep inactiv
|
|||||||
static const time_t MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ = 20 ; // don't ask for lobby list more than once every 30 secs.
|
static const time_t MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ = 20 ; // don't ask for lobby list more than once every 30 secs.
|
||||||
static const time_t LOBBY_LIST_AUTO_UPDATE_TIME = 121 ; // regularly ask for available lobbies every 5 minutes, to allow auto-subscribe to work
|
static const time_t LOBBY_LIST_AUTO_UPDATE_TIME = 121 ; // regularly ask for available lobbies every 5 minutes, to allow auto-subscribe to work
|
||||||
|
|
||||||
static const time_t DISTANT_CHAT_CLEANING_PERIOD = 60 ; // don't ask for lobby list more than once every 30 secs.
|
static const time_t DISTANT_CHAT_CLEANING_PERIOD = 60 ; // clean distant chat caches every 60 secs (remove old invites)
|
||||||
static const time_t DISTANT_CHAT_KEEP_ALIVE_PERIOD = 10 ; // sens keep alive distant chat packets every 10 secs.
|
static const time_t DISTANT_CHAT_KEEP_ALIVE_PERIOD = 10 ; // sens keep alive distant chat packets every 10 secs.
|
||||||
static const uint32_t DISTANT_CHAT_AES_KEY_SIZE = 16 ; // size of AES encryption key for distant chat.
|
static const uint32_t DISTANT_CHAT_AES_KEY_SIZE = 16 ; // size of AES encryption key for distant chat.
|
||||||
static const uint32_t DISTANT_CHAT_HASH_SIZE = 20 ; // This is sha1 size in bytes.
|
static const uint32_t DISTANT_CHAT_HASH_SIZE = 20 ; // This is sha1 size in bytes.
|
||||||
@ -125,8 +125,12 @@ int p3ChatService::tick()
|
|||||||
std::vector<VisibleChatLobbyRecord> visible_lobbies_tmp ;
|
std::vector<VisibleChatLobbyRecord> visible_lobbies_tmp ;
|
||||||
getListOfNearbyChatLobbies(visible_lobbies_tmp) ;
|
getListOfNearbyChatLobbies(visible_lobbies_tmp) ;
|
||||||
|
|
||||||
|
if (visible_lobbies_tmp.size()==0){
|
||||||
|
last_req_chat_lobby_list = now-LOBBY_LIST_AUTO_UPDATE_TIME+MIN_DELAY_BETWEEN_PUBLIC_LOBBY_REQ;
|
||||||
|
} else {
|
||||||
last_req_chat_lobby_list = now ;
|
last_req_chat_lobby_list = now ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Flush items that could not be sent, probably because of a Mutex protected zone.
|
// Flush items that could not be sent, probably because of a Mutex protected zone.
|
||||||
//
|
//
|
||||||
@ -435,11 +439,11 @@ void p3ChatService::locked_printDebugInfo() const
|
|||||||
std::cerr << " \"" << std::hex << it->first << "\" flags = " << it->second << std::dec << std::endl;
|
std::cerr << " \"" << std::hex << it->first << "\" flags = " << it->second << std::dec << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::isLobbyId(const std::string& id,ChatLobbyId& lobby_id)
|
bool p3ChatService::isLobbyId(const std::string& virtual_peer_id,ChatLobbyId& lobby_id)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
std::map<std::string,ChatLobbyId>::const_iterator it(_lobby_ids.find(id)) ;
|
std::map<std::string,ChatLobbyId>::const_iterator it(_lobby_ids.find(virtual_peer_id)) ;
|
||||||
|
|
||||||
if(it != _lobby_ids.end())
|
if(it != _lobby_ids.end())
|
||||||
{
|
{
|
||||||
@ -2017,10 +2021,10 @@ bool p3ChatService::loadList(std::list<RsItem*>& load)
|
|||||||
_default_nick_name = kit->value ;
|
_default_nick_name = kit->value ;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsChatLobbyConfigItem *cas = NULL ;
|
RsChatLobbyConfigItem *clci = NULL ;
|
||||||
|
|
||||||
if(NULL != (cas = dynamic_cast<RsChatLobbyConfigItem*>(*it)))
|
if(NULL != (clci = dynamic_cast<RsChatLobbyConfigItem*>(*it)))
|
||||||
_known_lobbies_flags[cas->lobby_Id] = ChatLobbyFlags(cas->flags) ;
|
_known_lobbies_flags[clci->lobby_Id] = ChatLobbyFlags(clci->flags) ;
|
||||||
|
|
||||||
// delete unknown items
|
// delete unknown items
|
||||||
delete *it;
|
delete *it;
|
||||||
@ -2088,6 +2092,8 @@ bool p3ChatService::saveList(bool& cleanup, std::list<RsItem*>& list)
|
|||||||
list.push_back(ei) ;
|
list.push_back(ei) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Save Default Nick Name */
|
||||||
|
|
||||||
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
|
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
|
||||||
RsTlvKeyValue kv;
|
RsTlvKeyValue kv;
|
||||||
kv.key = "DEFAULT_NICK_NAME" ;
|
kv.key = "DEFAULT_NICK_NAME" ;
|
||||||
@ -2099,11 +2105,11 @@ bool p3ChatService::saveList(bool& cleanup, std::list<RsItem*>& list)
|
|||||||
/* Save Lobby Auto Subscribe */
|
/* Save Lobby Auto Subscribe */
|
||||||
for(std::map<ChatLobbyId,ChatLobbyFlags>::const_iterator it=_known_lobbies_flags.begin();it!=_known_lobbies_flags.end();++it)
|
for(std::map<ChatLobbyId,ChatLobbyFlags>::const_iterator it=_known_lobbies_flags.begin();it!=_known_lobbies_flags.end();++it)
|
||||||
{
|
{
|
||||||
RsChatLobbyConfigItem *cas = new RsChatLobbyConfigItem ;
|
RsChatLobbyConfigItem *clci = new RsChatLobbyConfigItem ;
|
||||||
cas->lobby_Id=it->first;
|
clci->lobby_Id=it->first;
|
||||||
cas->flags=it->second.toUInt32();
|
clci->flags=it->second.toUInt32();
|
||||||
|
|
||||||
list.push_back(cas) ;
|
list.push_back(clci) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2515,16 +2521,16 @@ uint64_t p3ChatService::makeConnexionChallengeCode(const std::string& peer_id,Ch
|
|||||||
return result ;
|
return result ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::getChatLobbyList(std::list<ChatLobbyInfo>& linfos)
|
void p3ChatService::getChatLobbyList(std::list<ChatLobbyInfo>& cl_infos)
|
||||||
{
|
{
|
||||||
// fill up a dummy list for now.
|
// fill up a dummy list for now.
|
||||||
|
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
linfos.clear() ;
|
cl_infos.clear() ;
|
||||||
|
|
||||||
for(std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it(_chat_lobbys.begin());it!=_chat_lobbys.end();++it)
|
for(std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it(_chat_lobbys.begin());it!=_chat_lobbys.end();++it)
|
||||||
linfos.push_back(it->second) ;
|
cl_infos.push_back(it->second) ;
|
||||||
}
|
}
|
||||||
void p3ChatService::invitePeerToLobby(const ChatLobbyId& lobby_id, const std::string& peer_id,bool connexion_challenge)
|
void p3ChatService::invitePeerToLobby(const ChatLobbyId& lobby_id, const std::string& peer_id,bool connexion_challenge)
|
||||||
{
|
{
|
||||||
|
@ -163,9 +163,9 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
|||||||
*/
|
*/
|
||||||
bool clearPrivateChatQueue(bool incoming, const std::string &id);
|
bool clearPrivateChatQueue(bool incoming, const std::string &id);
|
||||||
|
|
||||||
bool getVirtualPeerId(const ChatLobbyId&, std::string& virtual_peer_id) ;
|
bool getVirtualPeerId(const ChatLobbyId& lobby_id, std::string& virtual_peer_id) ;
|
||||||
bool isLobbyId(const std::string&, ChatLobbyId&) ;
|
bool isLobbyId(const std::string& virtual_peer_id, ChatLobbyId& lobby_id) ;
|
||||||
void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >&) ;
|
void getChatLobbyList(std::list<ChatLobbyInfo, std::allocator<ChatLobbyInfo> >& cl_infos) ;
|
||||||
bool acceptLobbyInvite(const ChatLobbyId& id) ;
|
bool acceptLobbyInvite(const ChatLobbyId& id) ;
|
||||||
void denyLobbyInvite(const ChatLobbyId& id) ;
|
void denyLobbyInvite(const ChatLobbyId& id) ;
|
||||||
void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
|
void getPendingChatLobbyInvites(std::list<ChatLobbyInvite>& invites) ;
|
||||||
|
Loading…
Reference in New Issue
Block a user