mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 17:14:52 -07:00
store sessions in database
This commit is contained in:
parent
a7f3ce4050
commit
1455c093cc
8 changed files with 52 additions and 2 deletions
|
|
@ -82,6 +82,9 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
|||
users.insert(name, session);
|
||||
qDebug() << "Server::loginUser: name=" << name;
|
||||
|
||||
session->setSessionId(startSession(name, session->getAddress()));
|
||||
qDebug() << "session id:" << session->getSessionId();
|
||||
|
||||
Event_UserJoined *event = new Event_UserJoined(new ServerInfo_User(data, false));
|
||||
for (int i = 0; i < clients.size(); ++i)
|
||||
if (clients[i]->getAcceptsUserListChanges())
|
||||
|
|
@ -111,6 +114,10 @@ void Server::removeClient(Server_ProtocolHandler *client)
|
|||
|
||||
users.remove(data->getName());
|
||||
qDebug() << "Server::removeClient: name=" << data->getName();
|
||||
|
||||
if (client->getSessionId() != -1)
|
||||
endSession(client->getSessionId());
|
||||
qDebug() << "closed session id:" << client->getSessionId();
|
||||
}
|
||||
qDebug() << "Server::removeClient:" << clients.size() << "clients; " << users.size() << "users left";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ protected:
|
|||
QMap<QString, Server_ProtocolHandler *> users;
|
||||
QMap<int, Server_Room *> rooms;
|
||||
|
||||
virtual int startSession(const QString &userName, const QString &address) = 0;
|
||||
virtual void endSession(int sessionId) = 0;
|
||||
virtual bool userExists(const QString &user) = 0;
|
||||
virtual AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password) = 0;
|
||||
virtual ServerInfo_User *getUserData(const QString &name) = 0;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
#include <QDateTime>
|
||||
|
||||
Server_ProtocolHandler::Server_ProtocolHandler(Server *_server, QObject *parent)
|
||||
: QObject(parent), server(_server), authState(PasswordWrong), acceptsUserListChanges(false), acceptsRoomListChanges(false), userInfo(0), timeRunning(0), lastDataReceived(0), gameListMutex(QMutex::Recursive)
|
||||
: QObject(parent), server(_server), authState(PasswordWrong), acceptsUserListChanges(false), acceptsRoomListChanges(false), userInfo(0), sessionId(-1), timeRunning(0), lastDataReceived(0), gameListMutex(QMutex::Recursive)
|
||||
{
|
||||
connect(server, SIGNAL(pingClockTimeout()), this, SLOT(pingClockTimeout()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ protected:
|
|||
|
||||
void prepareDestroy();
|
||||
virtual bool getCompressionSupport() const = 0;
|
||||
int sessionId;
|
||||
private:
|
||||
QList<ProtocolItem *> itemQueue;
|
||||
QList<int> messageSizeOverTime, messageCountOverTime;
|
||||
|
|
@ -110,6 +111,8 @@ public:
|
|||
void setUserInfo(ServerInfo_User *_userInfo) { userInfo = _userInfo; }
|
||||
const QMap<QString, ServerInfo_User *> &getBuddyList() const { return buddyList; }
|
||||
const QMap<QString, ServerInfo_User *> &getIgnoreList() const { return ignoreList; }
|
||||
int getSessionId() const { return sessionId; }
|
||||
void setSessionId(int _sessionId) { sessionId = _sessionId; }
|
||||
|
||||
int getLastCommandTime() const { return timeRunning - lastDataReceived; }
|
||||
void processCommandContainer(CommandContainer *cont);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue