[prev in list] [next in list] [prev in thread] [next in thread]
List: atlantik-devel
Subject: [atlantik-cvs]
From: kde () office ! kde ! org
Date: 2003-07-27 23:03:07
[Download RAW message or body]
Update of /home/kde/kdegames/atlantik/atlanticd
In directory office:/tmp/cvs-serv37
Modified Files:
Makefile.am atlanticdaemon.cpp atlanticdaemon.h
serversocket.cpp serversocket.h
Added Files:
atlanticclient.cpp atlanticclient.h
Removed Files:
socket.cpp socket.h
Log Message:
preparations for ever using this
--- NEW FILE: atlanticclient.cpp ---
// Copyright (c) 2002 Rob Kaper <cap@capsi.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
#include <qtextstream.h>
#include <qtimer.h>
#include "atlanticclient.h"
#include "atlanticclient.moc"
AtlanticClient::AtlanticClient(QObject *parent, const char *name) : QSocket(parent, \
name) {
connect(this, SIGNAL(readyRead()), this, SLOT(readData()));
}
void AtlanticClient::sendData(const QString &data)
{
writeBlock(data.latin1(), data.length());
}
void AtlanticClient::readData()
{
if (canReadLine())
{
emit clientInput(this, readLine());
// There might be more data
QTimer::singleShot(0, this, SLOT(readData()));
}
else
{
// Maximum message size. Messages won't get bigger than 32k anyway, so
// if we didn't receive a newline by now, we probably won't anyway.
if (bytesAvailable() > (1024 * 32))
flush();
}
}
--- NEW FILE: atlanticclient.h ---
// Copyright (c) 2002-2003 Rob Kaper <cap@capsi.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
#ifndef CLIENT_H
#define CLIENT_H
#include <qsocket.h>
class AtlanticClient : public QSocket
{
Q_OBJECT
public:
AtlanticClient(QObject *parent = 0, const char *name = 0);
void sendData(const QString &data);
private slots:
void readData();
signals:
void clientInput(AtlanticClient *client, const QString &data);
};
#endif
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdegames/atlantik/atlanticd/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.am 11 May 2002 22:34:20 -0000 1.5
+++ Makefile.am 27 Jul 2003 23:03:03 -0000 1.6
@@ -5,6 +5,6 @@
INCLUDES = -I$(top_srcdir)/atlantik/libatlantic $(QT_INCLUDES)
LDADD = ../libatlantic/libatlantic.la
-atlanticd_SOURCES = atlanticdaemon.cpp main.cpp serversocket.cpp socket.cpp
+atlanticd_SOURCES = atlanticclient.cpp atlanticdaemon.cpp main.cpp serversocket.cpp
METASOURCES = AUTO
Index: atlanticdaemon.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/atlanticd/atlanticdaemon.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- atlanticdaemon.cpp 23 Apr 2002 16:56:30 -0000 1.5
+++ atlanticdaemon.cpp 27 Jul 2003 23:03:03 -0000 1.6
@@ -20,12 +20,16 @@
#include <atlantic_core.h>
+#include "atlanticclient.h"
+#include "atlanticdaemon.h"
#include "atlanticdaemon.moc"
#include "serversocket.h"
AtlanticDaemon::AtlanticDaemon()
{
m_serverSocket = new ServerSocket(1234, 100);
+ connect(m_serverSocket, SIGNAL(newClient(AtlanticClient *)), this, \
SLOT(newClient(AtlanticClient *))); +
m_atlanticCore = new AtlanticCore(this, "atlanticCore");
// Create socket for Monopigator
@@ -43,12 +47,21 @@
void AtlanticDaemon::monopigatorConnected()
{
- QString get;
- get = "GET /register.php?host=capsi.com&port=1234&version=atlanticd-prototype \
HTTP/1.1\nHost: gator.monopd.net\n\n";
-
+ QString get = "GET \
/register.php?host=capsi.com&port=1234&version=atlanticd-prototype HTTP/1.1\nHost: \
gator.monopd.net\n\n"; m_monopigatorSocket->writeBlock(get.latin1(), get.length());
m_monopigatorSocket->close();
- // Monopigator clears old entries, so keep registering every 90s
- QTimer::singleShot(90000, this, SLOT(monopigatorRegister()));
+ // Monopigator clears old entries, so keep registering every 180s
+ QTimer::singleShot(180000, this, SLOT(monopigatorRegister()));
+}
+
+void AtlanticDaemon::newClient(AtlanticClient *client)
+{
+ m_clients.append(client);
+
+ connect(client, SIGNAL(clientInput(AtlanticClient *, const QString &)), this, \
SLOT(clientInput(AtlanticClient *, const QString &))); +}
+
+void AtlanticDaemon::clientInput(AtlanticClient *client, const QString &data)
+{
}
Index: atlanticdaemon.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/atlanticd/atlanticdaemon.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- atlanticdaemon.h 23 Apr 2002 16:56:30 -0000 1.4
+++ atlanticdaemon.h 27 Jul 2003 23:03:03 -0000 1.5
@@ -17,10 +17,12 @@
#ifndef ATLANTIC_ATLANTICDAEMON_H
#define ATLANTIC_ATLANTICDAEMON_H
+#include <qptrlist.h>
+
class QSocket;
class AtlanticCore;
-
+class AtlanticClient;
class ServerSocket;
class AtlanticDaemon : public QObject
@@ -33,12 +35,14 @@
private slots:
void monopigatorRegister();
void monopigatorConnected();
+ void newClient(AtlanticClient *client);
+ void clientInput(AtlanticClient *client, const QString &data);
private:
QSocket *m_monopigatorSocket;
ServerSocket *m_serverSocket;
AtlanticCore *m_atlanticCore;
-
+ QPtrList<AtlanticClient> m_clients;
};
#endif
Index: serversocket.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/atlanticd/serversocket.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- serversocket.cpp 23 Apr 2002 16:56:30 -0000 1.4
+++ serversocket.cpp 27 Jul 2003 23:03:03 -0000 1.5
@@ -1,4 +1,4 @@
-// Copyright (c) 2002 Rob Kaper <cap@capsi.com>
+// Copyright (c) 2002-2003 Rob Kaper <cap@capsi.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -14,8 +14,8 @@
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
+#include "atlanticclient.h"
#include "serversocket.h"
-#include "socket.h"
ServerSocket::ServerSocket(int port, int backlog) : QServerSocket(port, backlog)
{
@@ -23,12 +23,8 @@
void ServerSocket::newConnection(int socket)
{
- Socket *newSocket = new Socket(this, "socket");
- newSocket->setSocket(socket);
+ AtlanticClient *client = new AtlanticClient(this, "socket");
+ client->setSocket(socket);
- QString intro;
- intro = "<monopd><server name=\"atlanticd\" version=\"prototype\"/><client \
clientid=\"-1\" cookie=\"?\"/></monopd>\n";
- newSocket->writeBlock(intro.latin1(), intro.length());
- // TODO: send list of supported games
- // TODO: send list of available games
+ emit newClient(client);
}
Index: serversocket.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/atlanticd/serversocket.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- serversocket.h 23 Apr 2002 16:56:30 -0000 1.3
+++ serversocket.h 27 Jul 2003 23:03:03 -0000 1.4
@@ -14,14 +14,22 @@
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
-#include <qserversocket.h>
-
#ifndef SERVERSOCKET_H
#define SERVERSOCKET_H
+
+#include <qserversocket.h>
+
+class AtlanticClient;
+
class ServerSocket : public QServerSocket
{
+Q_OBJECT
+
public:
ServerSocket(int port, int backlog);
void newConnection(int socket);
+
+signals:
+ void newClient(AtlanticClient *client);
};
#endif
--- socket.cpp DELETED ---
--- socket.h DELETED ---
_______________________________________________
atlantik-cvs mailing list
atlantik-cvs@mail.kde.org
http://mail.kde.org/mailman/listinfo/atlantik-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic