Adopting changes from asio branch. Currently broken.
This commit is contained in:
@@ -86,22 +86,7 @@ ClientStateInit::Process(ClientThread &client)
|
||||
if (context.GetServerPort() < 1024)
|
||||
throw ClientException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0);
|
||||
|
||||
client.SetContextSocket(socket(context.GetAddrFamily(), SOCK_STREAM, context.GetProtocol()));
|
||||
if (!IS_VALID_SOCKET(context.GetSocket()))
|
||||
throw ClientException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
||||
|
||||
unsigned long mode = 1;
|
||||
if (IOCTLSOCKET(context.GetSocket(), FIONBIO, &mode) == SOCKET_ERROR)
|
||||
throw ClientException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
||||
|
||||
// The following calls are optional - the return value is not checked.
|
||||
int nodelay = 1;
|
||||
setsockopt(context.GetSocket(), SOL_SOCKET, TCP_NODELAY, (char *)&nodelay, sizeof(nodelay));
|
||||
|
||||
#ifdef SO_NOSIGPIPE
|
||||
int nosigpipe = 1;
|
||||
setsockopt(context.GetSocket(), SOL_SOCKET, SO_NOSIGPIPE, (char *)&nosigpipe, sizeof(nosigpipe));
|
||||
#endif
|
||||
client.CreateContextSession();
|
||||
|
||||
if (context.GetUseServerList())
|
||||
client.SetState(ClientStateStartServerListDownload::Instance());
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <net/socket_helper.h>
|
||||
#include <net/clientthread.h>
|
||||
#include <net/clientstate.h>
|
||||
@@ -40,6 +41,7 @@
|
||||
#define TEMP_AVATAR_FILENAME "avatar.tmp"
|
||||
|
||||
using namespace std;
|
||||
using boost::asio::ip::tcp;
|
||||
|
||||
|
||||
class ClientSenderCallback : public SenderCallback, public SessionDataCallback
|
||||
@@ -719,14 +721,29 @@ ClientThread::GetContext()
|
||||
}
|
||||
|
||||
void
|
||||
ClientThread::SetContextSocket(SOCKET s)
|
||||
ClientThread::CreateContextSession()
|
||||
{
|
||||
GetContext().SetSessionData(boost::shared_ptr<SessionData>(new SessionData(
|
||||
s,
|
||||
SESSION_ID_GENERIC,
|
||||
m_senderThread,
|
||||
*m_senderCallback,
|
||||
*m_ioService)));
|
||||
bool validSocket = false;
|
||||
// TODO ipv6
|
||||
// TODO sctp
|
||||
try {
|
||||
boost::shared_ptr<tcp::socket> newSock(new boost::asio::ip::tcp::socket(*m_ioService, tcp::v4()));
|
||||
boost::asio::socket_base::non_blocking_io command(true);
|
||||
newSock->io_control(command);
|
||||
newSock->set_option(tcp::no_delay(true));
|
||||
newSock->set_option(boost::asio::socket_base::keep_alive(true));
|
||||
|
||||
GetContext().SetSessionData(boost::shared_ptr<SessionData>(new SessionData(
|
||||
newSock,
|
||||
SESSION_ID_GENERIC,
|
||||
m_senderThread,
|
||||
*m_senderCallback)));
|
||||
validSocket = true;
|
||||
} catch (...)
|
||||
{
|
||||
}
|
||||
if (!validSocket)
|
||||
throw ClientException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
||||
}
|
||||
|
||||
ClientState &
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
using namespace std;
|
||||
|
||||
ConnectData::ConnectData()
|
||||
: m_sockfd(INVALID_SOCKET), m_peerAddrSize(sizeof(m_peerAddr))
|
||||
: m_sockfd(INVALID_SOCKET), m_peerAddrSize(sizeof(struct sockaddr_storage))
|
||||
{
|
||||
memset(&m_peerAddr, 0, sizeof(m_peerAddr));
|
||||
}
|
||||
@@ -34,11 +34,3 @@ ConnectData::~ConnectData()
|
||||
CLOSESOCKET(m_sockfd);
|
||||
}
|
||||
|
||||
SOCKET
|
||||
ConnectData::ReleaseSocket()
|
||||
{
|
||||
SOCKET tmpSock = m_sockfd;
|
||||
m_sockfd = INVALID_SOCKET;
|
||||
return tmpSock;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ ReceiverHelper::Recv(SOCKET sock, ReceiveBuffer &buf)
|
||||
else
|
||||
{
|
||||
buf.recvBufUsed += bytesRecvd;
|
||||
InternalGetPackets(buf);
|
||||
ScanPackets(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ ReceiverHelper::Recv(SOCKET sock, ReceiveBuffer &buf)
|
||||
}
|
||||
|
||||
void
|
||||
ReceiverHelper::InternalGetPackets(ReceiveBuffer &buf)
|
||||
ReceiverHelper::ScanPackets(ReceiveBuffer &buf)
|
||||
{
|
||||
bool dataAvailable = true;
|
||||
do
|
||||
|
||||
@@ -17,28 +17,22 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <net/socket_helper.h>
|
||||
#include <net/serveracceptthread.h>
|
||||
#include <net/servercontext.h>
|
||||
#include <net/ircthread.h>
|
||||
#include <net/connectdata.h>
|
||||
#include <net/serverlobbythread.h>
|
||||
#include <net/serverexception.h>
|
||||
#include <net/socket_msg.h>
|
||||
#include <net/socket_startup.h>
|
||||
#include <core/loghelper.h>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
#define ACCEPT_TIMEOUT_MSEC 50
|
||||
#define NET_SERVER_LISTEN_BACKLOG 5
|
||||
|
||||
using namespace std;
|
||||
using boost::asio::ip::tcp;
|
||||
|
||||
ServerAcceptThread::ServerAcceptThread(ServerCallback &serverCallback)
|
||||
: m_serverCallback(serverCallback)
|
||||
ServerAcceptThread::ServerAcceptThread(ServerCallback &serverCallback, boost::shared_ptr<boost::asio::io_service> ioService)
|
||||
: m_ioService(ioService), m_serverCallback(serverCallback)
|
||||
{
|
||||
m_context.reset(new ServerContext);
|
||||
m_acceptor.reset(new tcp::acceptor(*m_ioService));
|
||||
}
|
||||
|
||||
ServerAcceptThread::~ServerAcceptThread()
|
||||
@@ -46,24 +40,85 @@ ServerAcceptThread::~ServerAcceptThread()
|
||||
}
|
||||
|
||||
void
|
||||
ServerAcceptThread::Init(unsigned serverPort, bool ipv6, bool sctp, const string &pwd, const string &logDir, boost::shared_ptr<ServerLobbyThread> lobbyThread)
|
||||
ServerAcceptThread::Listen(unsigned serverPort, bool ipv6, bool sctp, const string &pwd, const string &logDir, boost::shared_ptr<ServerLobbyThread> lobbyThread)
|
||||
{
|
||||
if (IsRunning())
|
||||
{
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ServerContext &context = GetContext();
|
||||
|
||||
context.SetProtocol(sctp ? SOCKET_IPPROTO_SCTP : 0);
|
||||
// If a "dual stack" is available, the pokerth server always uses ipv6.
|
||||
// In this case, ipv4 requests will be mapped to ipv6.
|
||||
context.SetAddrFamily(socket_has_dual_stack() ? AF_INET6 : (ipv6 ? AF_INET6 : AF_INET));
|
||||
context.SetServerPort(serverPort);
|
||||
|
||||
m_lobbyThread = lobbyThread;
|
||||
GetLobbyThread().Init(pwd, logDir);
|
||||
|
||||
try
|
||||
{
|
||||
InternalListen(serverPort, ipv6, sctp);
|
||||
}
|
||||
catch (const PokerTHException &e)
|
||||
{
|
||||
LOG_ERROR(e.what());
|
||||
GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// This is probably an asio exception. Assume that bind failed,
|
||||
// which is the most frequent case.
|
||||
LOG_ERROR("Cannot bind/listen on TCP port.");
|
||||
GetCallback().SignalNetServerError(ERR_SOCK_BIND_FAILED, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerAcceptThread::InternalListen(unsigned serverPort, bool ipv6, bool sctp)
|
||||
{
|
||||
if (serverPort < 1024)
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0);
|
||||
|
||||
// TODO consider sctp
|
||||
// Prepare Listen.
|
||||
if (ipv6)
|
||||
m_endpoint.reset(new tcp::endpoint(tcp::v6(), serverPort));
|
||||
else
|
||||
m_endpoint.reset(new tcp::endpoint(tcp::v4(), serverPort));
|
||||
|
||||
// TODO use non blocking I/O
|
||||
//boost::asio::socket_base::non_blocking_io command(true);
|
||||
//m_acceptor->io_control(command);
|
||||
m_acceptor->open(m_endpoint->protocol());
|
||||
m_acceptor->set_option(tcp::acceptor::reuse_address(true));
|
||||
if (ipv6) // In IPv6 mode: Be compatible with IPv4.
|
||||
m_acceptor->set_option(boost::asio::ip::v6_only(false));
|
||||
m_acceptor->bind(*m_endpoint);
|
||||
m_acceptor->listen(NET_SERVER_LISTEN_BACKLOG);
|
||||
|
||||
// Start first asynchronous Accept.
|
||||
boost::shared_ptr<tcp::socket> newSocket(new tcp::socket(*m_ioService));
|
||||
m_acceptor->async_accept(
|
||||
*newSocket,
|
||||
boost::bind(&ServerAcceptThread::HandleAccept, this, newSocket,
|
||||
boost::asio::placeholders::error)
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
ServerAcceptThread::HandleAccept(boost::shared_ptr<boost::asio::ip::tcp::socket> acceptedSocket,
|
||||
const boost::system::error_code& error)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
boost::asio::socket_base::non_blocking_io command(true);
|
||||
acceptedSocket->io_control(command);
|
||||
acceptedSocket->set_option(tcp::no_delay(true));
|
||||
acceptedSocket->set_option(boost::asio::socket_base::keep_alive(true));
|
||||
GetLobbyThread().AddConnection(acceptedSocket);
|
||||
|
||||
boost::shared_ptr<tcp::socket> newSocket(new tcp::socket(*m_ioService));
|
||||
m_acceptor->async_accept(
|
||||
*newSocket,
|
||||
boost::bind(&ServerAcceptThread::HandleAccept, this, newSocket,
|
||||
boost::asio::placeholders::error)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Accept failed. This is a fatal error.
|
||||
LOG_ERROR("In boost::asio handler: Accept failed.");
|
||||
GetCallback().SignalNetServerError(ERR_SOCK_ACCEPT_FAILED, 0);
|
||||
}
|
||||
}
|
||||
|
||||
ServerCallback &
|
||||
@@ -72,166 +127,6 @@ ServerAcceptThread::GetCallback()
|
||||
return m_serverCallback;
|
||||
}
|
||||
|
||||
void
|
||||
ServerAcceptThread::Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
Listen();
|
||||
|
||||
while (!ShouldTerminate())
|
||||
{
|
||||
// The main server thread is simple. It only accepts connections.
|
||||
AcceptLoop();
|
||||
}
|
||||
} catch (const PokerTHException &e)
|
||||
{
|
||||
GetCallback().SignalNetServerError(e.GetErrorId(), e.GetOsErrorCode());
|
||||
LOG_ERROR(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerAcceptThread::Listen()
|
||||
{
|
||||
ServerContext &context = GetContext();
|
||||
|
||||
if (context.GetServerPort() < 1024)
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_INVALID_PORT, 0);
|
||||
|
||||
#ifdef _WIN32
|
||||
context.SetSocket(WSASocket(context.GetAddrFamily(), SOCK_STREAM, context.GetProtocol(), 0, 0, WSA_FLAG_OVERLAPPED));
|
||||
#else
|
||||
context.SetSocket(socket(context.GetAddrFamily(), SOCK_STREAM, context.GetProtocol()));
|
||||
#endif
|
||||
|
||||
if (!IS_VALID_SOCKET(context.GetSocket()))
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
||||
|
||||
unsigned long mode = 1;
|
||||
if (IOCTLSOCKET(context.GetSocket(), FIONBIO, &mode) == SOCKET_ERROR)
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
||||
|
||||
// The following three calls are optional. If they fail, we don't care.
|
||||
int reuse = 1;
|
||||
setsockopt(context.GetSocket(), SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse));
|
||||
int nodelay = 1;
|
||||
setsockopt(context.GetSocket(), SOL_SOCKET, TCP_NODELAY, (char *)&nodelay, sizeof(nodelay));
|
||||
// Enable dual-stack socket on Windows Vista.
|
||||
if (context.GetAddrFamily() == AF_INET6)
|
||||
{
|
||||
int ipv6only = 0;
|
||||
setsockopt(context.GetSocket(), IPPROTO_IPV6, IPV6_V6ONLY, (char *)&ipv6only, sizeof(ipv6only));
|
||||
}
|
||||
|
||||
context.GetServerSockaddr()->ss_family = context.GetAddrFamily();
|
||||
|
||||
const char *localAddr = (context.GetAddrFamily() == AF_INET6) ? "::0" : "0.0.0.0";
|
||||
if (!socket_string_to_addr(
|
||||
localAddr,
|
||||
context.GetAddrFamily(),
|
||||
(struct sockaddr *)context.GetServerSockaddr(),
|
||||
context.GetServerSockaddrSize()))
|
||||
{
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_SET_ADDR_FAILED, 0);
|
||||
}
|
||||
if (!socket_set_port(
|
||||
context.GetServerPort(),
|
||||
context.GetAddrFamily(),
|
||||
(struct sockaddr *)context.GetServerSockaddr(),
|
||||
context.GetServerSockaddrSize()))
|
||||
{
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_SET_PORT_FAILED, 0);
|
||||
}
|
||||
|
||||
if (!IS_VALID_BIND(bind(
|
||||
context.GetSocket(),
|
||||
(const struct sockaddr *)context.GetServerSockaddr(),
|
||||
context.GetServerSockaddrSize())))
|
||||
{
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_BIND_FAILED, SOCKET_ERRNO());
|
||||
}
|
||||
|
||||
if (!IS_VALID_LISTEN(listen(context.GetSocket(), NET_SERVER_LISTEN_BACKLOG)))
|
||||
{
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_LISTEN_FAILED, SOCKET_ERRNO());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerAcceptThread::AcceptLoop()
|
||||
{
|
||||
ServerContext &context = GetContext();
|
||||
|
||||
fd_set readSet;
|
||||
struct timeval timeout;
|
||||
|
||||
FD_ZERO(&readSet);
|
||||
FD_SET(context.GetSocket(), &readSet);
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = ACCEPT_TIMEOUT_MSEC * 1000;
|
||||
int selectResult = select(context.GetSocket() + 1, &readSet, NULL, NULL, &timeout);
|
||||
if (!IS_VALID_SELECT(selectResult))
|
||||
{
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_SELECT_FAILED, SOCKET_ERRNO());
|
||||
}
|
||||
if (selectResult > 0) // accept is possible
|
||||
{
|
||||
boost::shared_ptr<ConnectData> tmpData(new ConnectData);
|
||||
tmpData->SetSocket(accept(context.GetSocket(), NULL, NULL));
|
||||
|
||||
if (!IS_VALID_SOCKET(tmpData->GetSocket()))
|
||||
{
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_ACCEPT_FAILED, SOCKET_ERRNO());
|
||||
}
|
||||
unsigned long mode = 1;
|
||||
if (IOCTLSOCKET(tmpData->GetSocket(), FIONBIO, &mode) == SOCKET_ERROR)
|
||||
{
|
||||
throw ServerException(__FILE__, __LINE__, ERR_SOCK_CREATION_FAILED, SOCKET_ERRNO());
|
||||
}
|
||||
|
||||
// Retrieve peer address.
|
||||
socklen_t addrLen = (socklen_t)context.GetServerSockaddrSize();
|
||||
if (getpeername(tmpData->GetSocket(), tmpData->GetPeerAddr(), &addrLen) != 0)
|
||||
{
|
||||
// Something went wrong with the connection, just continue (socket will be closed).
|
||||
LOG_ERROR("getpeername() failed: " << SOCKET_ERRNO());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the size of the peer address.
|
||||
tmpData->SetPeerAddrSize(addrLen);
|
||||
|
||||
// Optional calls - don't check return value.
|
||||
// Enable keepalive - won't be of much use but better than nothing.
|
||||
int keepalive = 1;
|
||||
setsockopt(tmpData->GetSocket(), SOL_SOCKET, SO_KEEPALIVE, (char *)&keepalive, sizeof(keepalive));
|
||||
|
||||
#ifdef SO_NOSIGPIPE
|
||||
int nosigpipe = 1;
|
||||
setsockopt(tmpData->GetSocket(), SOL_SOCKET, SO_NOSIGPIPE, (char *)&nosigpipe, sizeof(nosigpipe));
|
||||
#endif
|
||||
|
||||
GetLobbyThread().AddConnection(tmpData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ServerContext &
|
||||
ServerAcceptThread::GetContext() const
|
||||
{
|
||||
assert(m_context.get());
|
||||
return *m_context;
|
||||
}
|
||||
|
||||
ServerContext &
|
||||
ServerAcceptThread::GetContext()
|
||||
{
|
||||
assert(m_context.get());
|
||||
return *m_context;
|
||||
}
|
||||
|
||||
ServerLobbyThread &
|
||||
ServerAcceptThread::GetLobbyThread()
|
||||
{
|
||||
|
||||
@@ -20,26 +20,23 @@
|
||||
#include <net/servercontext.h>
|
||||
|
||||
ServerContext::ServerContext()
|
||||
: m_sockfd(INVALID_SOCKET), m_protocol(0), m_addrFamily(AF_INET), m_serverPort(0)
|
||||
: m_protocol(0), m_addrFamily(AF_INET), m_serverPort(0)
|
||||
{
|
||||
bzero(&m_serverSockaddr, sizeof(m_serverSockaddr));
|
||||
}
|
||||
|
||||
ServerContext::~ServerContext()
|
||||
{
|
||||
if (m_sockfd != INVALID_SOCKET)
|
||||
CLOSESOCKET(m_sockfd);
|
||||
}
|
||||
|
||||
SOCKET
|
||||
ServerContext::GetSocket() const
|
||||
{
|
||||
return m_sockfd;
|
||||
return m_sock;
|
||||
}
|
||||
|
||||
void
|
||||
ServerContext::SetSocket(SOCKET sockfd)
|
||||
ServerContext::SetSocket(SOCKET sock)
|
||||
{
|
||||
m_sockfd = sockfd;
|
||||
m_sock = sock;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#define SERVER_STATISTICS_STR_CUR_PLAYERS "CurPlayersLoggedIn"
|
||||
|
||||
using namespace std;
|
||||
using boost::asio::ip::tcp;
|
||||
|
||||
|
||||
class ServerSenderCallback : public SenderCallback, public SessionDataCallback
|
||||
@@ -80,12 +81,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ConfigFile *playerConfig, AvatarManager &avatarManager)
|
||||
: m_curBanId(0), m_gui(gui), m_avatarManager(avatarManager), m_playerConfig(playerConfig),
|
||||
ServerLobbyThread::ServerLobbyThread(GuiInterface &gui, ConfigFile *playerConfig, AvatarManager &avatarManager,
|
||||
boost::shared_ptr<boost::asio::io_service> ioService)
|
||||
: m_ioService(ioService), m_curBanId(0), m_gui(gui), m_avatarManager(avatarManager), m_playerConfig(playerConfig),
|
||||
m_curGameId(0), m_curUniquePlayerId(0), m_curSessionId(INVALID_SESSION + 1),
|
||||
m_statDataChanged(false), m_startTime(boost::posix_time::second_clock::local_time())
|
||||
{
|
||||
m_ioService.reset(new boost::asio::io_service());
|
||||
m_senderCallback.reset(new ServerSenderCallback(*this));
|
||||
m_sender.reset(new SenderThread(*m_senderCallback, m_ioService));
|
||||
m_receiver.reset(new ReceiverHelper);
|
||||
@@ -114,10 +115,10 @@ ServerLobbyThread::Init(const string &pwd, const string &logDir)
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::AddConnection(boost::shared_ptr<ConnectData> data)
|
||||
ServerLobbyThread::AddConnection(boost::shared_ptr<tcp::socket> sock)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_connectQueueMutex);
|
||||
m_connectQueue.push_back(data);
|
||||
m_connectQueue.push_back(sock);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -442,6 +443,18 @@ ServerLobbyThread::Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
m_timerManager.RegisterTimer(
|
||||
SERVER_CHECK_SESSION_TIMEOUTS_INTERVAL_MSEC,
|
||||
boost::bind(&ServerLobbyThread::TimerCheckSessionTimeouts, this),
|
||||
true);
|
||||
m_timerManager.RegisterTimer(
|
||||
SERVER_CACHE_CLEANUP_INTERVAL_SEC * 1000,
|
||||
boost::bind(&ServerLobbyThread::TimerCleanupAvatarCache, this),
|
||||
true);
|
||||
m_timerManager.RegisterTimer(
|
||||
SERVER_SAVE_STATISTICS_INTERVAL_SEC * 1000,
|
||||
boost::bind(&ServerLobbyThread::TimerSaveStatisticsFile, this),
|
||||
true);
|
||||
m_sender->Start();
|
||||
|
||||
while (!ShouldTerminate())
|
||||
@@ -450,22 +463,17 @@ ServerLobbyThread::Main()
|
||||
NewConnectionLoop();
|
||||
// Process re-added sessions.
|
||||
NewSessionLoop();
|
||||
// Main loop.
|
||||
ProcessLoop();
|
||||
// Remove games.
|
||||
RemoveGameLoop();
|
||||
// Kick players.
|
||||
RemovePlayerLoop();
|
||||
// Resubscribe Lobby Messages if needed.
|
||||
ResubscribeLobbyMsgLoop();
|
||||
// Check session timeouts.
|
||||
CheckSessionTimeoutsLoop();
|
||||
// Update avatar limitation lock.
|
||||
UpdateAvatarClientTimerLoop();
|
||||
// Cleanup cache.
|
||||
CleanupAvatarCache();
|
||||
// Save statistics if needed.
|
||||
SaveStatisticsFile();
|
||||
// Process timers.
|
||||
m_timerManager.Process();
|
||||
Thread::Msleep(10);
|
||||
}
|
||||
} catch (const PokerTHException &e)
|
||||
{
|
||||
@@ -486,70 +494,104 @@ ServerLobbyThread::Main()
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::ProcessLoop()
|
||||
ServerLobbyThread::HandleRead(SessionId sessionId, const boost::system::error_code& error, size_t bytesRead)
|
||||
{
|
||||
// Wait for data.
|
||||
SessionWrapper session = m_sessionManager.Select(RECV_TIMEOUT_MSEC);
|
||||
|
||||
if (session.sessionData.get())
|
||||
SessionWrapper session = m_sessionManager.GetSessionById(sessionId);
|
||||
if (!session.sessionData)
|
||||
session = m_gameSessionManager.GetSessionById(sessionId);
|
||||
if (session.sessionData)
|
||||
{
|
||||
boost::shared_ptr<NetPacket> packet;
|
||||
try
|
||||
unsigned gameId = session.sessionData->GetGameId();
|
||||
if (!error)
|
||||
{
|
||||
// Receive the next packet.
|
||||
packet = GetReceiver().Recv(session.sessionData->GetSocket(), session.sessionData->GetReceiveBuffer());
|
||||
} catch (const NetException &)
|
||||
{
|
||||
// On error: Close this session.
|
||||
CloseSession(session);
|
||||
return;
|
||||
|
||||
ReceiveBuffer &buf = session.sessionData->GetReceiveBuffer();
|
||||
buf.recvBufUsed += bytesRead;
|
||||
GetReceiver().ScanPackets(buf);
|
||||
|
||||
while (!buf.receivedPackets.empty())
|
||||
{
|
||||
boost::shared_ptr<NetPacket> packet = buf.receivedPackets.front();
|
||||
buf.receivedPackets.pop_front();
|
||||
if (game)
|
||||
game->HandlePacket(session, packet);
|
||||
else
|
||||
HandlePacket(session, packet);
|
||||
}
|
||||
session.sessionData->GetAsioSocket()->async_read_some(
|
||||
boost::asio::buffer(buf.recvBuf + buf.recvBufUsed, RECV_BUF_SIZE - buf.recvBufUsed),
|
||||
boost::bind(
|
||||
&ServerLobbyThread::HandleRead,
|
||||
this,
|
||||
sessionId,
|
||||
boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::bytes_transferred));
|
||||
}
|
||||
if (!packet.get())
|
||||
LOG_VERBOSE("Select successful but no packet received for session #" << session.sessionData->GetId() << ".");
|
||||
else
|
||||
{
|
||||
if (packet->IsClientActivity())
|
||||
session.sessionData->ResetActivityTimer();
|
||||
// On error: Close this session.
|
||||
boost::shared_ptr<ServerGameThread> game;
|
||||
if (gameId)
|
||||
{
|
||||
GameMap::iterator pos = m_gameMap.find(joinGameData.gameId);
|
||||
|
||||
if (session.sessionData->GetState() == SessionData::Init)
|
||||
{
|
||||
if (packet->ToNetPacketInit())
|
||||
HandleNetPacketInit(session, *packet->ToNetPacketInit());
|
||||
else if (packet->ToNetPacketAvatarHeader())
|
||||
HandleNetPacketAvatarHeader(session, *packet->ToNetPacketAvatarHeader());
|
||||
else if (packet->ToNetPacketUnknownAvatar())
|
||||
HandleNetPacketUnknownAvatar(session, *packet->ToNetPacketUnknownAvatar());
|
||||
else
|
||||
SessionError(session, ERR_SOCK_INVALID_STATE);
|
||||
}
|
||||
else if (session.sessionData->GetState() == SessionData::ReceivingAvatar)
|
||||
{
|
||||
if (packet->ToNetPacketAvatarFile())
|
||||
HandleNetPacketAvatarFile(session, *packet->ToNetPacketAvatarFile());
|
||||
else if (packet->ToNetPacketAvatarEnd())
|
||||
HandleNetPacketAvatarEnd(session, *packet->ToNetPacketAvatarEnd());
|
||||
else
|
||||
SessionError(session, ERR_SOCK_INVALID_STATE);
|
||||
if (pos != m_gameMap.end())
|
||||
game = pos->second;
|
||||
}
|
||||
if (game)
|
||||
game->ErrorRemoveSession(session);
|
||||
else
|
||||
{
|
||||
if (packet->ToNetPacketRetrievePlayerInfo())
|
||||
HandleNetPacketRetrievePlayerInfo(session, *packet->ToNetPacketRetrievePlayerInfo());
|
||||
else if (packet->ToNetPacketRetrieveAvatar())
|
||||
HandleNetPacketRetrieveAvatar(session, *packet->ToNetPacketRetrieveAvatar());
|
||||
else if (packet->ToNetPacketResetTimeout())
|
||||
{}
|
||||
else if (packet->ToNetPacketUnsubscribeGameList())
|
||||
session.sessionData->ResetWantsLobbyMsg();
|
||||
else if (packet->ToNetPacketResubscribeGameList())
|
||||
InternalResubscribeMsg(session);
|
||||
else if (packet->ToNetPacketCreateGame())
|
||||
HandleNetPacketCreateGame(session, *packet->ToNetPacketCreateGame());
|
||||
else if (packet->ToNetPacketJoinGame())
|
||||
HandleNetPacketJoinGame(session, *packet->ToNetPacketJoinGame());
|
||||
else
|
||||
SessionError(session, ERR_SOCK_INVALID_STATE);
|
||||
}
|
||||
CloseSession(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::HandlePacket(SessionWrapper session, boost::shared_ptr<NetPacket> packet)
|
||||
{
|
||||
if (session.sessionData && packet)
|
||||
{
|
||||
if (packet->IsClientActivity())
|
||||
session.sessionData->ResetActivityTimer();
|
||||
|
||||
if (session.sessionData->GetState() == SessionData::Init)
|
||||
{
|
||||
if (packet->ToNetPacketInit())
|
||||
HandleNetPacketInit(session, *packet->ToNetPacketInit());
|
||||
else if (packet->ToNetPacketAvatarHeader())
|
||||
HandleNetPacketAvatarHeader(session, *packet->ToNetPacketAvatarHeader());
|
||||
else if (packet->ToNetPacketUnknownAvatar())
|
||||
HandleNetPacketUnknownAvatar(session, *packet->ToNetPacketUnknownAvatar());
|
||||
else
|
||||
SessionError(session, ERR_SOCK_INVALID_STATE);
|
||||
}
|
||||
else if (session.sessionData->GetState() == SessionData::ReceivingAvatar)
|
||||
{
|
||||
if (packet->ToNetPacketAvatarFile())
|
||||
HandleNetPacketAvatarFile(session, *packet->ToNetPacketAvatarFile());
|
||||
else if (packet->ToNetPacketAvatarEnd())
|
||||
HandleNetPacketAvatarEnd(session, *packet->ToNetPacketAvatarEnd());
|
||||
else
|
||||
SessionError(session, ERR_SOCK_INVALID_STATE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (packet->ToNetPacketRetrievePlayerInfo())
|
||||
HandleNetPacketRetrievePlayerInfo(session, *packet->ToNetPacketRetrievePlayerInfo());
|
||||
else if (packet->ToNetPacketRetrieveAvatar())
|
||||
HandleNetPacketRetrieveAvatar(session, *packet->ToNetPacketRetrieveAvatar());
|
||||
else if (packet->ToNetPacketResetTimeout())
|
||||
{}
|
||||
else if (packet->ToNetPacketUnsubscribeGameList())
|
||||
session.sessionData->ResetWantsLobbyMsg();
|
||||
else if (packet->ToNetPacketResubscribeGameList())
|
||||
InternalResubscribeMsg(session);
|
||||
else if (packet->ToNetPacketCreateGame())
|
||||
HandleNetPacketCreateGame(session, *packet->ToNetPacketCreateGame());
|
||||
else if (packet->ToNetPacketJoinGame())
|
||||
HandleNetPacketJoinGame(session, *packet->ToNetPacketJoinGame());
|
||||
else
|
||||
SessionError(session, ERR_SOCK_INVALID_STATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -923,7 +965,7 @@ void
|
||||
ServerLobbyThread::NewConnectionLoop()
|
||||
{
|
||||
// Handle one incoming connection at a time.
|
||||
boost::shared_ptr<ConnectData> tmpData;
|
||||
boost::shared_ptr<tcp::socket> tmpData;
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_connectQueueMutex);
|
||||
if (!m_connectQueue.empty())
|
||||
@@ -1020,18 +1062,6 @@ ServerLobbyThread::ResubscribeLobbyMsgLoop()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::CheckSessionTimeoutsLoop()
|
||||
{
|
||||
if (m_checkSessionTimeoutsTimer.elapsed().total_milliseconds() >= SERVER_CHECK_SESSION_TIMEOUTS_INTERVAL_MSEC)
|
||||
{
|
||||
m_sessionManager.ForEach(boost::bind(&ServerLobbyThread::InternalCheckSessionTimeouts, boost::ref(*this), _1));
|
||||
m_gameSessionManager.ForEach(boost::bind(&ServerLobbyThread::InternalCheckSessionTimeouts, boost::ref(*this), _1));
|
||||
m_checkSessionTimeoutsTimer.reset();
|
||||
m_checkSessionTimeoutsTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::UpdateAvatarClientTimerLoop()
|
||||
{
|
||||
@@ -1051,17 +1081,21 @@ ServerLobbyThread::UpdateAvatarClientTimerLoop()
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::CleanupAvatarCache()
|
||||
ServerLobbyThread::TimerCheckSessionTimeouts()
|
||||
{
|
||||
// Only act on timer and if there are no sessions.
|
||||
if (m_cacheCleanupTimer.elapsed().total_seconds() >= SERVER_CACHE_CLEANUP_INTERVAL_SEC
|
||||
&& !m_sessionManager.HasSessions() && !m_gameSessionManager.HasSessions())
|
||||
m_sessionManager.ForEach(boost::bind(&ServerLobbyThread::InternalCheckSessionTimeouts, boost::ref(*this), _1));
|
||||
m_gameSessionManager.ForEach(boost::bind(&ServerLobbyThread::InternalCheckSessionTimeouts, boost::ref(*this), _1));
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::TimerCleanupAvatarCache()
|
||||
{
|
||||
// Only act if there are no sessions.
|
||||
if (!m_sessionManager.HasSessions() && !m_gameSessionManager.HasSessions())
|
||||
{
|
||||
LOG_VERBOSE("Cleaning up avatar cache.");
|
||||
|
||||
m_avatarManager.RemoveOldAvatarCacheEntries();
|
||||
m_cacheCleanupTimer.reset();
|
||||
m_cacheCleanupTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1169,7 +1203,7 @@ ServerLobbyThread::TerminateGames()
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::HandleNewConnection(boost::shared_ptr<ConnectData> connData)
|
||||
ServerLobbyThread::HandleNewConnection(boost::shared_ptr<tcp::socket> sock)
|
||||
{
|
||||
// Create a random session id.
|
||||
// This id can be used to reconnect to the server if the connection was lost.
|
||||
@@ -1182,20 +1216,38 @@ ServerLobbyThread::HandleNewConnection(boost::shared_ptr<ConnectData> connData)
|
||||
//}
|
||||
|
||||
// Create a new session.
|
||||
boost::shared_ptr<SessionData> sessionData(new SessionData(connData->ReleaseSocket(), m_curSessionId++, m_sender, *m_senderCallback, *m_ioService));
|
||||
boost::shared_ptr<SessionData> sessionData(new SessionData(sock, m_curSessionId++, m_sender, *m_senderCallback));
|
||||
m_sessionManager.AddSession(sessionData);
|
||||
|
||||
LOG_VERBOSE("Accepted connection - session #" << sessionData->GetId() << ".");
|
||||
|
||||
bool hasClientIp = false;
|
||||
if (m_sessionManager.GetRawSessionCount() <= SERVER_MAX_NUM_SESSIONS)
|
||||
{
|
||||
char tmpAddress[MAX_ADDR_STRING_LEN];
|
||||
// Only consider address, set port to zero.
|
||||
if (socket_set_port(0, connData->GetPeerAddr()->sa_family, connData->GetPeerAddr(), connData->GetPeerAddrSize())
|
||||
&& socket_addr_to_string(connData->GetPeerAddr(), connData->GetPeerAddrSize(), connData->GetPeerAddr()->sa_family, tmpAddress, sizeof(tmpAddress)))
|
||||
boost::system::error_code errCode;
|
||||
tcp::endpoint clientEndpoint = sock->remote_endpoint(errCode);
|
||||
if (!errCode)
|
||||
{
|
||||
tmpAddress[sizeof(tmpAddress) - 1] = 0; // paranoia
|
||||
sessionData->SetClientAddr(tmpAddress);
|
||||
string ipAddress = clientEndpoint.address().to_string(errCode);
|
||||
if (!errCode && !ipAddress.empty())
|
||||
{
|
||||
sessionData->SetClientAddr(ipAddress);
|
||||
hasClientIp = true;
|
||||
sock->async_read_some(
|
||||
boost::asio::buffer(sessionData->GetReceiveBuffer().recvBuf, RECV_BUF_SIZE),
|
||||
boost::bind(
|
||||
&ServerLobbyThread::HandleRead,
|
||||
this,
|
||||
sessionData->GetId(),
|
||||
boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::bytes_transferred));
|
||||
}
|
||||
}
|
||||
if (!hasClientIp)
|
||||
{
|
||||
// We do not accept sessions if we cannot
|
||||
// retrieve the client address.
|
||||
SessionError(SessionWrapper(sessionData, boost::shared_ptr<PlayerData>()), ERR_NET_INVALID_SESSION);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1386,30 +1438,23 @@ ServerLobbyThread::ReadStatisticsFile()
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::SaveStatisticsFile()
|
||||
ServerLobbyThread::TimerSaveStatisticsFile()
|
||||
{
|
||||
if (m_saveStatisticsTimer.elapsed().total_seconds() >= SERVER_SAVE_STATISTICS_INTERVAL_SEC)
|
||||
LOG_VERBOSE("Saving statistics.");
|
||||
boost::mutex::scoped_lock lock(m_statMutex);
|
||||
if (m_statDataChanged)
|
||||
{
|
||||
LOG_VERBOSE("Saving statistics.");
|
||||
ofstream o(m_statisticsFileName.c_str(), ios_base::out | ios_base::trunc);
|
||||
if (!o.fail())
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_statMutex);
|
||||
if (m_statDataChanged)
|
||||
{
|
||||
ofstream o(m_statisticsFileName.c_str(), ios_base::out | ios_base::trunc);
|
||||
if (!o.fail())
|
||||
{
|
||||
o << SERVER_STATISTICS_STR_TOTAL_PLAYERS " " << m_statData.totalPlayersEverLoggedIn << endl;
|
||||
o << SERVER_STATISTICS_STR_TOTAL_GAMES " " << m_statData.totalGamesEverCreated << endl;
|
||||
o << SERVER_STATISTICS_STR_MAX_PLAYERS " " << m_statData.maxPlayersLoggedIn << endl;
|
||||
o << SERVER_STATISTICS_STR_MAX_GAMES " " << m_statData.maxGamesOpen << endl;
|
||||
o << SERVER_STATISTICS_STR_CUR_PLAYERS " " << m_statData.numberOfPlayersOnServer << endl;
|
||||
o << SERVER_STATISTICS_STR_CUR_GAMES " " << m_statData.numberOfGamesOpen << endl;
|
||||
m_statDataChanged = false;
|
||||
}
|
||||
}
|
||||
o << SERVER_STATISTICS_STR_TOTAL_PLAYERS " " << m_statData.totalPlayersEverLoggedIn << endl;
|
||||
o << SERVER_STATISTICS_STR_TOTAL_GAMES " " << m_statData.totalGamesEverCreated << endl;
|
||||
o << SERVER_STATISTICS_STR_MAX_PLAYERS " " << m_statData.maxPlayersLoggedIn << endl;
|
||||
o << SERVER_STATISTICS_STR_MAX_GAMES " " << m_statData.maxGamesOpen << endl;
|
||||
o << SERVER_STATISTICS_STR_CUR_PLAYERS " " << m_statData.numberOfPlayersOnServer << endl;
|
||||
o << SERVER_STATISTICS_STR_CUR_GAMES " " << m_statData.numberOfGamesOpen << endl;
|
||||
m_statDataChanged = false;
|
||||
}
|
||||
m_saveStatisticsTimer.reset();
|
||||
m_saveStatisticsTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ using namespace std;
|
||||
ServerManager::ServerManager(GuiInterface &gui, ConfigFile *config, AvatarManager &avatarManager)
|
||||
: m_gui(gui), m_playerConfig(config), m_avatarManager(avatarManager)
|
||||
{
|
||||
m_ioService.reset(new boost::asio::io_service());
|
||||
}
|
||||
|
||||
ServerManager::~ServerManager()
|
||||
@@ -48,19 +49,19 @@ ServerManager::~ServerManager()
|
||||
void
|
||||
ServerManager::Init(unsigned serverPort, bool ipv6, ServerNetworkMode mode, const string &pwd, const string &logDir, boost::shared_ptr<IrcThread> ircThread)
|
||||
{
|
||||
m_lobbyThread.reset(new ServerLobbyThread(GetGui(), m_playerConfig, m_avatarManager));
|
||||
m_lobbyThread.reset(new ServerLobbyThread(GetGui(), m_playerConfig, m_avatarManager, m_ioService));
|
||||
GetLobbyThread().Init(pwd, logDir);
|
||||
|
||||
if (mode & NETWORK_MODE_TCP)
|
||||
{
|
||||
boost::shared_ptr<ServerAcceptThread> tcpAcceptThread(new ServerAcceptThread(GetGui()));
|
||||
tcpAcceptThread->Init(serverPort, ipv6, false, pwd, logDir, m_lobbyThread);
|
||||
boost::shared_ptr<ServerAcceptThread> tcpAcceptThread(new ServerAcceptThread(GetGui(), m_ioService));
|
||||
tcpAcceptThread->Listen(serverPort, ipv6, false, pwd, logDir, m_lobbyThread);
|
||||
m_acceptThreadPool.push_back(tcpAcceptThread);
|
||||
}
|
||||
if (mode & NETWORK_MODE_SCTP)
|
||||
{
|
||||
boost::shared_ptr<ServerAcceptThread> sctpAcceptThread(new ServerAcceptThread(GetGui()));
|
||||
sctpAcceptThread->Init(serverPort, ipv6, true, pwd, logDir, m_lobbyThread);
|
||||
boost::shared_ptr<ServerAcceptThread> sctpAcceptThread(new ServerAcceptThread(GetGui(), m_ioService));
|
||||
sctpAcceptThread->Listen(serverPort, ipv6, true, pwd, logDir, m_lobbyThread);
|
||||
m_acceptThreadPool.push_back(sctpAcceptThread);
|
||||
}
|
||||
m_ircThread = ircThread;
|
||||
@@ -269,7 +270,7 @@ ServerManager::RunAll()
|
||||
if (m_ircThread)
|
||||
m_ircThread->Run();
|
||||
GetLobbyThread().Run();
|
||||
for_each(m_acceptThreadPool.begin(), m_acceptThreadPool.end(), boost::mem_fn(&ServerAcceptThread::Run));
|
||||
// for_each(m_acceptThreadPool.begin(), m_acceptThreadPool.end(), boost::mem_fn(&ServerAcceptThread::Run));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -298,7 +299,7 @@ ServerManager::SignalTerminationAll()
|
||||
if (m_ircThread)
|
||||
m_ircThread->SignalTermination();
|
||||
GetLobbyThread().SignalTermination();
|
||||
for_each(m_acceptThreadPool.begin(), m_acceptThreadPool.end(), boost::mem_fn(&ServerAcceptThread::SignalTermination));
|
||||
// for_each(m_acceptThreadPool.begin(), m_acceptThreadPool.end(), boost::mem_fn(&ServerAcceptThread::SignalTermination));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -307,16 +308,15 @@ ServerManager::JoinAll(bool wait)
|
||||
if (m_ircThread)
|
||||
m_ircThread->Join(wait ? NET_ADMIN_IRC_TERMINATE_TIMEOUT_MSEC : 0);
|
||||
bool lobbyThreadTerminated = GetLobbyThread().Join(wait ? NET_LOBBY_THREAD_TERMINATE_TIMEOUT_MSEC : 0);
|
||||
bool allAcceptThreadsTerminated = true;
|
||||
AcceptThreadList::iterator i = m_acceptThreadPool.begin();
|
||||
/* AcceptThreadList::iterator i = m_acceptThreadPool.begin();
|
||||
AcceptThreadList::iterator end = m_acceptThreadPool.end();
|
||||
while (i != end)
|
||||
{
|
||||
if (!(*i)->Join(wait ? NET_ACCEPT_THREAD_TERMINATE_TIMEOUT_MSEC : 0))
|
||||
allAcceptThreadsTerminated = false;
|
||||
++i;
|
||||
}
|
||||
return lobbyThreadTerminated || allAcceptThreadsTerminated;
|
||||
}*/
|
||||
return lobbyThreadTerminated;
|
||||
}
|
||||
|
||||
ServerLobbyThread &
|
||||
|
||||
@@ -20,13 +20,12 @@
|
||||
#include <net/sessiondata.h>
|
||||
#include <net/senderinterface.h>
|
||||
|
||||
SessionData::SessionData(SOCKET sockfd, SessionId id, boost::shared_ptr<SenderInterface> sender, SessionDataCallback &cb, boost::asio::io_service &ioService)
|
||||
: m_id(id), m_state(SessionData::Init), m_readyFlag(false),
|
||||
SessionData::SessionData(boost::shared_ptr<boost::asio::ip::tcp::socket> sock, SessionId id,
|
||||
boost::shared_ptr<SenderInterface> sender, SessionDataCallback &cb)
|
||||
: m_socket(sock), m_id(id), m_gameId(0), m_state(SessionData::Init), m_readyFlag(false),
|
||||
m_wantsLobbyMsg(true), m_activityTimeoutNoticeSent(false), m_callback(cb),
|
||||
m_maxNumPlayers(0)
|
||||
{
|
||||
m_socket.reset(new boost::asio::ip::tcp::socket(
|
||||
ioService, boost::asio::ip::tcp::v6(), sockfd));
|
||||
m_sender = sender;
|
||||
}
|
||||
|
||||
@@ -42,6 +41,20 @@ SessionData::GetId() const
|
||||
return m_id;
|
||||
}
|
||||
|
||||
unsigned
|
||||
SessionData::GetGameId() const
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||
return m_gameId;
|
||||
}
|
||||
|
||||
void
|
||||
SessionData::SetGameId(unsigned gameId)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_dataMutex);
|
||||
m_gameId = gameId;
|
||||
}
|
||||
|
||||
SessionData::State
|
||||
SessionData::GetState() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user