mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-19 11:54:22 -04:00
added leaving notification to chat lobby
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4743 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4236ad59a5
commit
b6f8e2a306
2 changed files with 42 additions and 29 deletions
|
@ -1399,7 +1399,7 @@ bool p3ChatService::recvLobbyChat(RsChatLobbyMsgItem *item)
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3ChatService::sendLobbyChat(const std::wstring& msg, const ChatLobbyId& lobby_id)
|
bool p3ChatService::sendLobbyChat(const std::wstring& msg, const ChatLobbyId& lobby_id,bool management)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
@ -1429,7 +1429,11 @@ bool p3ChatService::sendLobbyChat(const std::wstring& msg, const ChatLobbyId& lo
|
||||||
lobby.msg_cache[item.msg_id] = time(NULL) ; // put the msg in cache!
|
lobby.msg_cache[item.msg_id] = time(NULL) ; // put the msg in cache!
|
||||||
|
|
||||||
item.lobby_id = lobby_id ;
|
item.lobby_id = lobby_id ;
|
||||||
item.nick = lobby.nick_name ;
|
|
||||||
|
if(management)
|
||||||
|
item.nick = "Lobby management" ;
|
||||||
|
else
|
||||||
|
item.nick = lobby.nick_name ;
|
||||||
|
|
||||||
// chat msg stuff
|
// chat msg stuff
|
||||||
//
|
//
|
||||||
|
@ -1700,7 +1704,7 @@ bool p3ChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id)
|
||||||
// Copy string to wstring.
|
// Copy string to wstring.
|
||||||
std::copy(_default_nick_name.begin(), _default_nick_name.end(), wmsg.begin());
|
std::copy(_default_nick_name.begin(), _default_nick_name.end(), wmsg.begin());
|
||||||
|
|
||||||
sendLobbyChat(wmsg + L" joined the lobby",lobby_id) ;
|
sendLobbyChat(wmsg + L" joined the lobby",lobby_id,true) ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1794,38 +1798,47 @@ void p3ChatService::handleFriendUnsubscribeLobby(RsChatLobbyUnsubscribeItem *ite
|
||||||
|
|
||||||
void p3ChatService::unsubscribeChatLobby(const ChatLobbyId& id)
|
void p3ChatService::unsubscribeChatLobby(const ChatLobbyId& id)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
// send AKN item
|
||||||
|
std::string nick ;
|
||||||
std::map<ChatLobbyId,ChatLobbyEntry>::iterator it = _chat_lobbys.find(id) ;
|
getNickNameForChatLobby(id,nick) ;
|
||||||
|
std::wstring wmsg(nick.length(), L' '); // Make room for characters
|
||||||
|
std::copy(nick.begin(), nick.end(), wmsg.begin());
|
||||||
|
sendLobbyChat(wmsg + L" has left the lobby",id,true) ;
|
||||||
|
|
||||||
if(it == _chat_lobbys.end())
|
|
||||||
{
|
{
|
||||||
std::cerr << "Chat lobby " << id << " does not exist ! Can't unsubscribe!" << std::endl;
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
return ;
|
|
||||||
}
|
|
||||||
// send a lobby leaving packet to all friends
|
|
||||||
|
|
||||||
for(std::set<std::string>::const_iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
|
||||||
{
|
|
||||||
RsChatLobbyUnsubscribeItem *item = new RsChatLobbyUnsubscribeItem ;
|
|
||||||
|
|
||||||
item->lobby_id = id ;
|
std::map<ChatLobbyId,ChatLobbyEntry>::iterator it = _chat_lobbys.find(id) ;
|
||||||
item->PeerId(*it2) ;
|
|
||||||
|
|
||||||
sendItem(item) ;
|
if(it == _chat_lobbys.end())
|
||||||
}
|
|
||||||
|
|
||||||
// remove lobby information
|
|
||||||
|
|
||||||
_chat_lobbys.erase(it) ;
|
|
||||||
|
|
||||||
for(std::map<std::string,ChatLobbyId>::iterator it2(_lobby_ids.begin());it2!=_lobby_ids.end();++it2)
|
|
||||||
if(it2->second == id)
|
|
||||||
{
|
{
|
||||||
_lobby_ids.erase(it2) ;
|
std::cerr << "Chat lobby " << id << " does not exist ! Can't unsubscribe!" << std::endl;
|
||||||
break ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// send a lobby leaving packet to all friends
|
||||||
|
|
||||||
|
for(std::set<std::string>::const_iterator it2(it->second.participating_friends.begin());it2!=it->second.participating_friends.end();++it2)
|
||||||
|
{
|
||||||
|
RsChatLobbyUnsubscribeItem *item = new RsChatLobbyUnsubscribeItem ;
|
||||||
|
|
||||||
|
item->lobby_id = id ;
|
||||||
|
item->PeerId(*it2) ;
|
||||||
|
|
||||||
|
sendItem(item) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove lobby information
|
||||||
|
|
||||||
|
_chat_lobbys.erase(it) ;
|
||||||
|
|
||||||
|
for(std::map<std::string,ChatLobbyId>::iterator it2(_lobby_ids.begin());it2!=_lobby_ids.end();++it2)
|
||||||
|
if(it2->second == id)
|
||||||
|
{
|
||||||
|
_lobby_ids.erase(it2) ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
// done!
|
// done!
|
||||||
}
|
}
|
||||||
bool p3ChatService::setDefaultNickNameForChatLobby(const std::string& nick)
|
bool p3ChatService::setDefaultNickNameForChatLobby(const std::string& nick)
|
||||||
|
|
|
@ -214,7 +214,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor
|
||||||
|
|
||||||
/// receive and handle chat lobby item
|
/// receive and handle chat lobby item
|
||||||
bool recvLobbyChat(RsChatLobbyMsgItem*) ;
|
bool recvLobbyChat(RsChatLobbyMsgItem*) ;
|
||||||
bool sendLobbyChat(const std::wstring&, const ChatLobbyId&) ;
|
bool sendLobbyChat(const std::wstring&, const ChatLobbyId&,bool management = false) ;
|
||||||
void handleRecvLobbyInvite(RsChatLobbyInviteItem*) ;
|
void handleRecvLobbyInvite(RsChatLobbyInviteItem*) ;
|
||||||
void checkAndRedirectMsgToLobby(RsChatMsgItem*) ;
|
void checkAndRedirectMsgToLobby(RsChatMsgItem*) ;
|
||||||
void handleConnectionChallenge(RsChatLobbyConnectChallengeItem *item) ;
|
void handleConnectionChallenge(RsChatLobbyConnectChallengeItem *item) ;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue