mirror of
https://github.com/QuasarApp/Snake.git
synced 2025-04-28 10:44:42 +00:00
add base sql server
This commit is contained in:
parent
0e4ab11e2f
commit
fdc990e5ba
@ -69,7 +69,6 @@ HEADERS += \
|
||||
back-end/backgrounditem.h
|
||||
|
||||
DISTFILES += \
|
||||
doc/calassdiagramm.qmodel \
|
||||
android/AndroidManifest.xml \
|
||||
android/gradle/wrapper/gradle-wrapper.jar \
|
||||
android/gradlew \
|
||||
|
@ -11,3 +11,8 @@ QuasarAppLib.file = QuasarAppLib/QuasarApp.pro
|
||||
Snake.file = Snake/snake.pro
|
||||
|
||||
include($$PWD/installer/installer.pri)
|
||||
|
||||
|
||||
DISTFILES += \
|
||||
doc/librarymodel.qmodel \
|
||||
doc/calassdiagramm.qmodel
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "clientprotocol.h"
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class QTcpSocket;
|
||||
class Player;
|
||||
class BaseItem;
|
||||
|
@ -33,3 +33,4 @@ HEADERS += \
|
||||
|
||||
include($$PWD/../../QuasarAppLib/QuasarLib.pri)
|
||||
include($$PWD/../ServerProtocol/ServerProtocol.pri)
|
||||
include($$PWD/../Server/Server.pri)
|
||||
|
23
SnakeServer/Server/Server.pri
Normal file
23
SnakeServer/Server/Server.pri
Normal file
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Copyright (C) 2018 - 2019 QuasarApp.
|
||||
# Distributed under the lgplv3 software license, see the accompanying
|
||||
# Everyone is permitted to copy and distribute verbatim copies
|
||||
# of this license document, but changing it is not allowed.
|
||||
#
|
||||
|
||||
!isEmpty(SERVER_LIB):error("Server.pri already included")
|
||||
SERVER_LIB = 1
|
||||
|
||||
#DEPENDS
|
||||
CONFIG(release, debug|release): {
|
||||
SERVER_LIB_OUTPUT_DIR="$$PWD/build/release"
|
||||
} else {
|
||||
SERVER_LIB_OUTPUT_DIR="$$PWD/build/debug"
|
||||
}
|
||||
|
||||
LIBS += -L$$SERVER_LIB_OUTPUT_DIR -lServer
|
||||
|
||||
INCLUDEPATH += "$$PWD/"
|
||||
|
||||
|
||||
|
47
SnakeServer/Server/Server.pro
Normal file
47
SnakeServer/Server/Server.pro
Normal file
@ -0,0 +1,47 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2019-02-16T12:24:27
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT -= gui
|
||||
QT += network
|
||||
|
||||
TARGET = Server
|
||||
TEMPLATE = lib
|
||||
|
||||
DEFINES += SERVER_LIBRARY
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which has been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
server.cpp \
|
||||
sqldatabase.cpp
|
||||
|
||||
TARGET = Server
|
||||
|
||||
CONFIG(release, debug|release): {
|
||||
DESTDIR = $$PWD/build/release
|
||||
|
||||
} else {
|
||||
DESTDIR = $$PWD/build/debug
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
server.h \
|
||||
server_global.h \
|
||||
sqldatabase.h
|
||||
|
||||
include($$PWD/../../QuasarAppLib/QuasarLib.pri)
|
||||
include($$PWD/../ServerProtocol/ServerProtocol.pri)
|
||||
|
||||
RESOURCES += sqlres.qrc
|
11
SnakeServer/Server/server.cpp
Normal file
11
SnakeServer/Server/server.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "server.h"
|
||||
#include <spserver.h>
|
||||
|
||||
Server::Server(QObject *ptr):
|
||||
QObject (ptr) {
|
||||
_serverDaemon = new ServerProtocol::Server(this);
|
||||
_serverDaemon->run(DEFAULT_SERVER);
|
||||
}
|
||||
|
||||
Server::~Server() {
|
||||
}
|
21
SnakeServer/Server/server.h
Normal file
21
SnakeServer/Server/server.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef SERVER_H
|
||||
#define SERVER_H
|
||||
#include <serverprotocol.h>
|
||||
#include "server_global.h"
|
||||
|
||||
namespace ServerProtocol {
|
||||
class Server;
|
||||
}
|
||||
|
||||
class SERVERSHARED_EXPORT Server: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
ServerProtocol::Server *_serverDaemon = nullptr;
|
||||
|
||||
public:
|
||||
Server(QObject *ptr = nullptr);
|
||||
virtual ~Server();
|
||||
};
|
||||
|
||||
#endif // SERVER_H
|
12
SnakeServer/Server/server_global.h
Normal file
12
SnakeServer/Server/server_global.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef SERVER_GLOBAL_H
|
||||
#define SERVER_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(SERVER_LIBRARY)
|
||||
# define SERVERSHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define SERVERSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // SERVER_GLOBAL_H
|
33
SnakeServer/Server/sql/SnakeDB.sql
Normal file
33
SnakeServer/Server/sql/SnakeDB.sql
Normal file
@ -0,0 +1,33 @@
|
||||
CREATE TABLE IF NOT EXISTS items(
|
||||
id int NOT NULL AUTO_INCREMENT,
|
||||
type int NOT NULL,
|
||||
data BLOB NOT NULL,
|
||||
PRIMARY KEY(id)
|
||||
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS players(
|
||||
id int NOT NULL AUTO_INCREMENT,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
gmail VARCHAR(64) NOT NLLL,
|
||||
money int NOT NULL DEFAULT 0,
|
||||
avgrecord int NOT NULL DEFAULT 0,
|
||||
record int NOT NULL DEFAULT 0,
|
||||
lastOnline date not null DEFAULT 0,
|
||||
onlinetime int not null DEFAULT 0,
|
||||
currentsnake int not null DEFAULT 0,
|
||||
|
||||
PRIMARY KEY(id),
|
||||
|
||||
FOREIGN KEY(currentsnake) REFERENCES items(id)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE CASCADE
|
||||
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ovners(
|
||||
player int NOT NULL,
|
||||
item int NOT NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS iovners ON ovners(player,item);
|
6
SnakeServer/Server/sqldatabase.cpp
Normal file
6
SnakeServer/Server/sqldatabase.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "sqldatabase.h"
|
||||
|
||||
SQLDataBase::SQLDataBase(QObject *ptr):
|
||||
QObject (ptr) {
|
||||
|
||||
}
|
12
SnakeServer/Server/sqldatabase.h
Normal file
12
SnakeServer/Server/sqldatabase.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef SQLDATABASE_H
|
||||
#define SQLDATABASE_H
|
||||
#include <QObject>
|
||||
|
||||
class SQLDataBase : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SQLDataBase(QObject * ptr = nullptr);
|
||||
};
|
||||
|
||||
#endif // SQLDATABASE_H
|
5
SnakeServer/Server/sqlres.qrc
Normal file
5
SnakeServer/Server/sqlres.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/sql">
|
||||
<file alias="DB">sql/SnakeDB.sql</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -47,5 +47,6 @@ HEADERS += \
|
||||
serverutils.h \
|
||||
server.h \
|
||||
client.h \
|
||||
sp.h
|
||||
sp.h \
|
||||
spserver.h
|
||||
|
||||
|
6
SnakeServer/ServerProtocol/spserver.h
Normal file
6
SnakeServer/ServerProtocol/spserver.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef SPSERVER_H
|
||||
#define SPSERVER_H
|
||||
|
||||
#include "server.h"
|
||||
|
||||
#endif // SPSERVER_H
|
@ -5,6 +5,7 @@ CONFIG += ordered
|
||||
SUBDIRS += \
|
||||
ServerProtocol \
|
||||
ClientProtocol \
|
||||
Client \
|
||||
Terminal \
|
||||
Server \
|
||||
Daemon \
|
||||
serverProtocolTests
|
||||
serverProtocolTests \
|
||||
|
BIN
SnakeServer/Terminal/build/debug/Client
Executable file
BIN
SnakeServer/Terminal/build/debug/Client
Executable file
Binary file not shown.
BIN
SnakeServer/Terminal/build/debug/Terminal
Executable file
BIN
SnakeServer/Terminal/build/debug/Terminal
Executable file
Binary file not shown.
BIN
SnakeServer/Terminal/build/release/Client
Executable file
BIN
SnakeServer/Terminal/build/release/Client
Executable file
Binary file not shown.
@ -13,7 +13,11 @@ class testSankeServer : public QObject
|
||||
|
||||
private:
|
||||
void testPingServerProtockol();
|
||||
|
||||
void testPingClientProtockol();
|
||||
void testLoginClientProtockol();
|
||||
void testUserDataClientProtockol();
|
||||
void testGetItemClientProtockol();
|
||||
|
||||
public:
|
||||
testSankeServer();
|
||||
@ -131,7 +135,17 @@ void testSankeServer::testPingClientProtockol() {
|
||||
|
||||
delete serv;
|
||||
delete client;
|
||||
}
|
||||
|
||||
void testSankeServer::testLoginClientProtockol() {
|
||||
|
||||
}
|
||||
|
||||
void testSankeServer::testUserDataClientProtockol() {
|
||||
|
||||
}
|
||||
|
||||
void testSankeServer::testGetItemClientProtockol() {
|
||||
|
||||
}
|
||||
|
||||
@ -141,6 +155,10 @@ void testSankeServer::testServerProtockol() {
|
||||
|
||||
void testSankeServer::testClientProtockol() {
|
||||
testPingClientProtockol();
|
||||
|
||||
testLoginClientProtockol();
|
||||
testGetItemClientProtockol();
|
||||
testUserDataClientProtockol();
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(testSankeServer)
|
||||
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
1183
doc/librarymodel.qmodel
Normal file
1183
doc/librarymodel.qmodel
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user