summaryrefslogtreecommitdiffstats
path: root/signet/Client.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-10-12 16:51:32 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-10-12 16:51:32 +0000
commit03e65c78d1bc08bdaee86cf09a4dd8735b6a9fdd (patch)
treedcae9e046b80a64e638a741c148fcdec03bc0801 /signet/Client.cpp
parent2e4b02a9410fc51dc0c97bd4a9fd0b8c45bda27f (diff)
downloadsigen-03e65c78d1bc08bdaee86cf09a4dd8735b6a9fdd.tar.gz
sigen-03e65c78d1bc08bdaee86cf09a4dd8735b6a9fdd.tar.xz
sigen-03e65c78d1bc08bdaee86cf09a4dd8735b6a9fdd.zip
[FIX] Fleshing out Signet more
[DEL] Unused top-level directories git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@275 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'signet/Client.cpp')
-rw-r--r--signet/Client.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/signet/Client.cpp b/signet/Client.cpp
index 9a032407..a6d39011 100644
--- a/signet/Client.cpp
+++ b/signet/Client.cpp
@@ -21,6 +21,7 @@
// Signet includes
#include "Room.h"
#include "Server.h"
+#include "Table.h"
// Qt includes
#include <QtNetwork/QHostAddress>
@@ -42,17 +43,25 @@ void Signet::Client::setServer(Server* server)
void Signet::Client::joinRoom(Room* room)
{
+ if (!m_rooms.contains(room))
+ {
+ room->addClient(this);
+ m_rooms[room];
+ }
}
void Signet::Client::leaveRoom(Room* room)
{
+ QList<Table*> tables = QList<Table*>::fromSet(m_rooms[room]);
+ foreach (Table* table, tables)
+ table->removeClient(this);
+ room->removeClient(this);
}
void Signet::Client::joinTable(Room* room, Table* table)
{
if (!m_rooms.contains(room))
joinRoom(room);
-// table->
}
void Signet::Client::leaveTable(Room* room, Table* table)
@@ -66,6 +75,8 @@ void Signet::Client::leaveTable(Room* room, Table* table)
void Signet::Client::sendData(const QByteArray& data)
{
+ m_socket->write(data);
+// m_socket->waitForBytesWritten();
}
void Signet::Client::disconnectFromServer()
@@ -78,10 +89,5 @@ void Signet::Client::disconnectFromAllRooms()
{
QList<Room*> rooms = m_rooms.keys();
foreach (Room* room, rooms)
- {
- QList<Table*> tables = QList::fromSet(m_rooms[room]);
- foreach (Table* table, tables)
- table->removeClient(this);
- room->removeClient(this);
- }
+ leaveRoom(room);
}