Fixed leaving a game which has not yet been started.
This commit is contained in:
@@ -79,6 +79,10 @@ public:
|
|||||||
{return m_cacheDir;}
|
{return m_cacheDir;}
|
||||||
void SetCacheDir(const std::string &cacheDir)
|
void SetCacheDir(const std::string &cacheDir)
|
||||||
{m_cacheDir = cacheDir;}
|
{m_cacheDir = cacheDir;}
|
||||||
|
bool GetSubscribeLobbyMsg() const
|
||||||
|
{return m_hasSubscribedLobbyMsg;}
|
||||||
|
void SetSubscribeLobbyMsg(bool setSubscribe)
|
||||||
|
{m_hasSubscribedLobbyMsg = setSubscribe;}
|
||||||
|
|
||||||
int GetClientSockaddrSize() const
|
int GetClientSockaddrSize() const
|
||||||
{return m_addrFamily == AF_INET6 ? sizeof(sockaddr_in6) : sizeof(sockaddr_in);}
|
{return m_addrFamily == AF_INET6 ? sizeof(sockaddr_in6) : sizeof(sockaddr_in);}
|
||||||
@@ -99,6 +103,7 @@ private:
|
|||||||
std::string m_playerName;
|
std::string m_playerName;
|
||||||
std::string m_avatarFile;
|
std::string m_avatarFile;
|
||||||
std::string m_cacheDir;
|
std::string m_cacheDir;
|
||||||
|
bool m_hasSubscribedLobbyMsg;
|
||||||
ReceiveBuffer m_receiveBuffer;
|
ReceiveBuffer m_receiveBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,8 @@
|
|||||||
#include <net/clientcontext.h>
|
#include <net/clientcontext.h>
|
||||||
|
|
||||||
ClientContext::ClientContext()
|
ClientContext::ClientContext()
|
||||||
: m_protocol(0), m_addrFamily(AF_INET), m_useServerList(false), m_serverPort(0)
|
: m_protocol(0), m_addrFamily(AF_INET), m_useServerList(false), m_serverPort(0),
|
||||||
|
m_hasSubscribedLobbyMsg(true)
|
||||||
{
|
{
|
||||||
bzero(&m_clientSockaddr, sizeof(m_clientSockaddr));
|
bzero(&m_clientSockaddr, sizeof(m_clientSockaddr));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -591,19 +591,27 @@ ClientThread::SetUnknownAvatar(unsigned playerId)
|
|||||||
void
|
void
|
||||||
ClientThread::UnsubscribeLobbyMsg()
|
ClientThread::UnsubscribeLobbyMsg()
|
||||||
{
|
{
|
||||||
|
if (GetContext().GetSubscribeLobbyMsg())
|
||||||
|
{
|
||||||
// Send unsubscribe request.
|
// Send unsubscribe request.
|
||||||
boost::shared_ptr<NetPacket> unsubscr(new NetPacketUnsubscribeGameList);
|
boost::shared_ptr<NetPacket> unsubscr(new NetPacketUnsubscribeGameList);
|
||||||
GetSender().Send(GetContext().GetSessionData(), unsubscr);
|
GetSender().Send(GetContext().GetSessionData(), unsubscr);
|
||||||
|
GetContext().SetSubscribeLobbyMsg(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientThread::ResubscribeLobbyMsg()
|
ClientThread::ResubscribeLobbyMsg()
|
||||||
{
|
{
|
||||||
|
if (!GetContext().GetSubscribeLobbyMsg())
|
||||||
|
{
|
||||||
// Clear game info map as it is outdated.
|
// Clear game info map as it is outdated.
|
||||||
ClearGameInfoMap();
|
ClearGameInfoMap();
|
||||||
// Send resubscribe request.
|
// Send resubscribe request.
|
||||||
boost::shared_ptr<NetPacket> resubscr(new NetPacketResubscribeGameList);
|
boost::shared_ptr<NetPacket> resubscr(new NetPacketResubscribeGameList);
|
||||||
GetSender().Send(GetContext().GetSessionData(), resubscr);
|
GetSender().Send(GetContext().GetSessionData(), resubscr);
|
||||||
|
GetContext().SetSubscribeLobbyMsg(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ClientContext &
|
const ClientContext &
|
||||||
|
|||||||
Reference in New Issue
Block a user