summaryrefslogtreecommitdiff
path: root/netcore.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2014-01-22 09:31:30 +0100
committerTreeki <treeki@gmail.com>2014-01-22 09:31:30 +0100
commite3e6a3f2c422a6b82b234f575a6b3bad459e5e0b (patch)
tree411f501c1e5ee85228607d1440df341be0b66c4c /netcore.cpp
parentf458a0b65de5db40ecb57d5831117305fc4dd876 (diff)
downloadbounce4-e3e6a3f2c422a6b82b234f575a6b3bad459e5e0b.tar.gz
bounce4-e3e6a3f2c422a6b82b234f575a6b3bad459e5e0b.zip
add window management, move hacky Python client over to PyQt5
Diffstat (limited to '')
-rw-r--r--netcore.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/netcore.cpp b/netcore.cpp
index 27769a6..4341787 100644
--- a/netcore.cpp
+++ b/netcore.cpp
@@ -8,6 +8,8 @@ NetCore::NetCore() {
serverCount = 0;
for (int i = 0; i < SERVER_LIMIT; i++)
servers[i] = NULL;
+
+ nextWindowID = 1;
}
Client *NetCore::findClientWithSessionKey(uint8_t *key) const {
@@ -24,6 +26,7 @@ int NetCore::registerServer(Server *server) {
int id = serverCount++;
servers[id] = server;
+ server->attachedToCore();
return id;
}
void NetCore::deregisterServer(int id) {
@@ -251,8 +254,54 @@ int NetCore::execute() {
}
+
+int NetCore::registerWindow(Window *window) {
+ window->id = nextWindowID;
+ nextWindowID++;
+
+ windows.push_back(window);
+
+
+ Buffer pkt;
+ pkt.writeU32(1);
+ window->syncStateForClient(pkt);
+
+ for (int i = 0; i < clientCount; i++)
+ if (clients[i]->isAuthed())
+ clients[i]->sendPacket(Packet::B2C_WINDOW_ADD, pkt);
+}
+
+void NetCore::deregisterWindow(Window *window) {
+ Buffer pkt;
+ pkt.writeU32(1);
+ pkt.writeU32(window->id);
+
+ for (int i = 0; i < clientCount; i++)
+ if (clients[i]->isAuthed())
+ clients[i]->sendPacket(Packet::B2C_WINDOW_REMOVE, pkt);
+
+ windows.remove(window);
+}
+
+Window *NetCore::findWindow(int id) const {
+ std::list<Window *>::const_iterator
+ i = windows.begin(),
+ e = windows.end();
+
+ for (; i != e; ++i)
+ if ((*i)->id == id)
+ return *i;
+
+ return 0;
+}
+
+
+
+
Client *Bouncer::constructClient() {
return new MobileClient(this);
}
+
+