next steps pokerthcleaner, read config file with badwords and settings, warn + kick procedure

This commit is contained in:
doitux
2009-07-19 23:14:27 +00:00
parent 7513742d29
commit 4acc9ec234
12 changed files with 856 additions and 42 deletions
+31 -12
View File
@@ -5,19 +5,26 @@
#include <stdlib.h>
#include "messagefilter.h"
#include "cleanerconfig.h"
CleanerServer::CleanerServer()
CleanerServer::CleanerServer(): config(0)
{
myMessageFilter = new MessageFilter;
tcpServer = new QTcpServer();
if (!tcpServer->listen(QHostAddress("127.0.0.1"), 7777) ) {
qDebug() << QString("Unable to start the server: %1.").arg(tcpServer->errorString());
return;
}
config = new CleanerConfig;
myMessageFilter = new MessageFilter(config);
tcpServer = new QTcpServer();
tcpServer->setMaxPendingConnections(1);
if (!tcpServer->listen(QHostAddress(QString::fromUtf8(config->readConfigString("HostAddress").c_str())), config->readConfigInt("DefaultListenPort")) ) {
qDebug() << QString("Unable to start the server: %1.").arg(tcpServer->errorString());
return;
}
qDebug() << QString("The server is running on port %1.").arg(tcpServer->serverPort());
qDebug() << QString("The server is running on port %1.").arg(tcpServer->serverPort());
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(newCon()));
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(newCon()));
refreshConfig();
}
CleanerServer::~CleanerServer()
@@ -32,9 +39,21 @@ void CleanerServer::newCon()
void CleanerServer::onRead()
{
char buf[20000];
char buf[1024];
tcpSocket->readLine(buf, sizeof(buf));
QString message = QString::fromUtf8("%1").arg(buf);
QString checkMessage = myMessageFilter->check(message);
// TESTING DEFAULT VALUES
QString nick = "PlayerNick";
unsigned playerId = 1;
// TESTING DEFAULT VALUES
QString checkMessage = myMessageFilter->check(playerId, nick, message);
tcpSocket->write(checkMessage.toAscii().data(), checkMessage.length());
}
void CleanerServer::refreshConfig() {
// config->fillBuffer();
myMessageFilter->refreshConfig();
}