diff --git a/.gitignore b/.gitignore
index a8aebb8..d640ac9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,5 @@ connectionStrings.config
.idea/
cmake-build-*/
*.db-journal
-scape.db
\ No newline at end of file
+scape.db
+memory.db
\ No newline at end of file
diff --git a/PROTOCOL.md b/PROTOCOL.md
index 3238b6c..6488a67 100644
--- a/PROTOCOL.md
+++ b/PROTOCOL.md
@@ -240,15 +240,20 @@ Communication between the master server and clients will be done over a WebSocke
Iterated over n (0 ≤ i ≤ n - 1 )
- 2 + 2i
+ 2 + 3i
Server Id
Packed Unsigned Short
- 3 + 2i
+ 3 + 3i
+ Server Name
+ Text
+
+ 4 + 3i
User Count
Packed Unsigned Short
+
#### Client to Master [Encrypted]
diff --git a/resources/server/config.ini b/resources/server/config.ini
index 1b352a1..49eea95 100644
--- a/resources/server/config.ini
+++ b/resources/server/config.ini
@@ -3,7 +3,7 @@ Run Master = true
Master Host = localhost
Master Port = 8008
-[Defaults]
+[Pool Defaults]
; amount of threads to start with (never close)
Initial Count = 3
; starting limit of clients per thread
@@ -30,11 +30,14 @@ Port = 8008
[Slave]
Port = 9000
Name = Test Server 1
+Max Users = 100
[Slave]
Port = 9001
Name = Test Server 2
+Max Users = 100
[Slave]
Port = 9002
-Name = Test Server 3
\ No newline at end of file
+Name = Test Server 3
+Max Users = 100
\ No newline at end of file
diff --git a/src/server/db/database.cpp b/src/server/db/database.cpp
index 3b5f19b..88c4b5b 100644
--- a/src/server/db/database.cpp
+++ b/src/server/db/database.cpp
@@ -13,7 +13,11 @@ bool sosc::db::init_databases(std::string* error) {
return true;
_ctx.ready = true;
+#ifdef SOSC_DEBUG
+ sqlite3_open(SOSC_RESC("memory.db").c_str(), &_ctx.mem_db);
+#else
sqlite3_open(":memory:", &_ctx.mem_db);
+#endif
for(const auto& query : _mem_db_sql)
sqlite3_exec(_ctx.mem_db, query, nullptr, nullptr, nullptr);
diff --git a/src/server/hosts/master_client.cpp b/src/server/hosts/master_client.cpp
index 91f8651..cbc2af1 100644
--- a/src/server/hosts/master_client.cpp
+++ b/src/server/hosts/master_client.cpp
@@ -16,7 +16,7 @@ void sosc::MasterClientPool::SetupQueries(db::Queries *queries) {
#define QRY_USER_MAIL_REG_CHECK 1
queries->push_back(new db::Query(
"SELECT COUNT(*) FROM `USERS` "
- "WHERE `USERNAME` = ?"
+ "WHERE `EMAIL` = ?"
));
#define QRY_USER_REGISTER 2
@@ -171,7 +171,7 @@ bool sosc::MasterClient::ProcessRegistration(Packet &pck) {
query->BindText(pck[2], 3);
query->NonQuery();
- this->sock.Send(Packet(kRegisterResponse, {"\1", 0x000}));
+ this->sock.Send(Packet(kRegisterResponse, {"\1", HTONUS(0x000)}));
return true;
}
diff --git a/src/server/hosts/slave.cpp b/src/server/hosts/slave.cpp
index 5d4caa4..b95c3bb 100644
--- a/src/server/hosts/slave.cpp
+++ b/src/server/hosts/slave.cpp
@@ -1,5 +1,7 @@
#include "slave.hpp"
+/** SLAVE -> CLIENT **/
+
sosc::SlaveClient::SlaveClient(const ScapeConnection& client) {
this->sock = client;
}
@@ -13,3 +15,6 @@ bool sosc::SlaveClient::Close(const Packet& message) {
this->sock.Send(message);
return this->Close();
}
+
+/** SLAVE -> MASTER **/
+
diff --git a/src/server/hosts/slave.hpp b/src/server/hosts/slave.hpp
index fbe15d0..aaaf592 100644
--- a/src/server/hosts/slave.hpp
+++ b/src/server/hosts/slave.hpp
@@ -1,6 +1,7 @@
#ifndef SOSC_HOST_SLAVE_H
#define SOSC_HOST_SLAVE_H
+#include "sock/intrasock.hpp"
#include "sock/scapesock.hpp"
#include "sock/pool.hpp"
#include "ctx/slave.hpp"
@@ -32,6 +33,20 @@ protected:
return true;
}
};
+
+/** SLAVE -> MASTER **/
+
+class SlaveMaster {
+public:
+ SlaveMaster();
+
+
+
+ bool Close();
+ bool Close(const Packet& message);
+private:
+ IntraClient sock;
+};
}
#endif
diff --git a/src/server/main.cpp b/src/server/main.cpp
index e564e29..b27015d 100644
--- a/src/server/main.cpp
+++ b/src/server/main.cpp
@@ -74,7 +74,7 @@ int main(int argc, char **argv) {
ini::Field("master host", ini::Field::STRING),
ini::Field("master port", ini::Field::UINT32),
}),
- ini::Rule("defaults", true, false, {
+ ini::Rule("pool defaults", true, false, {
ini::Field("initial count", ini::Field::UINT32),
ini::Field("initial size", ini::Field::UINT32),
ini::Field("size growth", ini::Field::UINT32),
@@ -93,6 +93,7 @@ int main(int argc, char **argv) {
ini::Rule("slave", false, true, {
ini::Field("port", ini::Field::UINT32),
ini::Field("name", ini::Field::STRING),
+ ini::Field("max users", ini::Field::STRING),
})
});
} catch(const std::exception& e) {
@@ -101,7 +102,7 @@ int main(int argc, char **argv) {
}
poolinfo_t info;
- configure_poolinfo(&_ctx.default_info, (*config)["defaults"][0]);
+ configure_poolinfo(&_ctx.default_info, (*config)["pool defaults"][0]);
if((*config)["general"]["run master"]) {
if(!config->HasSection("master to client") ||
@@ -152,7 +153,7 @@ int main(int argc, char **argv) {
}
}
- std::cout << "Server threads started. Type STOP to cancel." << std::endl;
+ std::cout << "Server threads started. Type STOP to quit." << std::endl;
std::string input;
while(true) {
@@ -181,7 +182,7 @@ bool master_intra_start(uint16_t port, const sosc::poolinfo_t& info) {
_ctx.master_intra->thread = std::thread([&] {
sosc::IntraClient client;
- while (_ctx.master_intra->server.Accept(&client))
+ while(_ctx.master_intra->server.Accept(&client))
_ctx.master_intra->pool.AddClient(new sosc::MasterIntra(client));
});
@@ -213,7 +214,7 @@ bool slave_start(uint16_t port, const sosc::poolinfo_t& info, slave_ctx* ctx) {
ctx->thread = std::thread([&] {
sosc::ScapeConnection client;
- while (ctx->server.Accept(&client))
+ while(ctx->server.Accept(&client))
ctx->pool.AddClient(new sosc::SlaveClient(client));
});
diff --git a/src/web/index.html b/src/web/index.html
index e706606..a7bb032 100644
--- a/src/web/index.html
+++ b/src/web/index.html
@@ -46,8 +46,29 @@
+
-
+