[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Camino-devel] camino/src camino.pro client/ClientEngine.cpp c...
From: |
Philippe Fremy |
Subject: |
[Camino-devel] camino/src camino.pro client/ClientEngine.cpp c... |
Date: |
Sun, 26 Jan 2003 14:39:41 -0500 |
CVSROOT: /cvsroot/camino
Module name: camino
Changes by: Philippe Fremy <address@hidden> 03/01/26 14:39:40
Modified files:
src : camino.pro
src/client : ClientEngine.cpp ClientEngine.h
src/common : MsgDecoder.h
src/server : CaminoServer.cpp CaminoServer.h
ServerDialog.cpp
Added files:
src/server : Player.cpp Player.h
Log message:
add player name transmission/reception to server
Patches:
Index: camino/src/camino.pro
diff -u camino/src/camino.pro:1.14 camino/src/camino.pro:1.15
--- camino/src/camino.pro:1.14 Sun Jan 26 13:10:57 2003
+++ camino/src/camino.pro Sun Jan 26 14:39:40 2003
@@ -21,10 +21,12 @@
HEADERS += server/ServerDialog.h
HEADERS += server/ServerEngine.h
HEADERS += server/CaminoServer.h
+HEADERS += server/Player.h
SOURCES += server/ServerDialog.cpp
SOURCES += server/ServerEngine.cpp
SOURCES += server/CaminoServer.cpp
+SOURCES += server/Player.cpp
# client
FORMS += client/DialogConnectionUI.ui
Index: camino/src/client/ClientEngine.cpp
diff -u camino/src/client/ClientEngine.cpp:1.1
camino/src/client/ClientEngine.cpp:1.2
--- camino/src/client/ClientEngine.cpp:1.1 Sun Jan 26 13:10:57 2003
+++ camino/src/client/ClientEngine.cpp Sun Jan 26 14:39:40 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: ClientEngine.cpp,v 1.1 2003/01/26 18:10:57 pfremy Exp $
+** Version : $Id: ClientEngine.cpp,v 1.2 2003/01/26 19:39:40 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -27,6 +27,7 @@
#include <qsocket.h>
// application specific include files
#include "ClientEngine.h"
+#include "common/MsgCoder.h"
/** add comments here */
@@ -37,6 +38,8 @@
connect( _socket, SIGNAL( connected() ), SLOT( slotServerConnected() )
);
connect( _socket, SIGNAL( connectionClosed() ), SLOT(
slotConnectionClosed() ) );
connect( _socket, SIGNAL( readyRead() ), SLOT( slotDecode() ) );
+
+ _send = new MsgCoder( _socket );
}
void ClientEngine::connectToServer( const QString & serverName, int port,
const QString & playerName )
@@ -46,12 +49,17 @@
qDebug("IP: %d", port );
qDebug("Player name : %s", playerName.latin1() );
+ _playerName = playerName;
+
_socket->connectToHost( serverName, port );
}
void ClientEngine::slotServerConnected()
{
qDebug("ClientEngine - Connection with server established!");
+ qDebug("ClientEngine - send player name " );
+ _send->connectServer( _playerName );
+ qDebug("ClientEngine - send player name - done" );
}
void ClientEngine::slotConnectionClosed()
Index: camino/src/client/ClientEngine.h
diff -u camino/src/client/ClientEngine.h:1.1
camino/src/client/ClientEngine.h:1.2
--- camino/src/client/ClientEngine.h:1.1 Sun Jan 26 13:10:57 2003
+++ camino/src/client/ClientEngine.h Sun Jan 26 14:39:40 2003
@@ -5,7 +5,7 @@
** ClientEngine.h
** The intelligence of the client is here
**
-** Version : $Id: ClientEngine.h,v 1.1 2003/01/26 18:10:57 pfremy Exp $
+** Version : $Id: ClientEngine.h,v 1.2 2003/01/26 19:39:40 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -30,8 +30,11 @@
// generic include files
// include files for QT
+#include <qstring.h>
+
// application specific include files
#include "common/MsgDecoder.h"
+#include "common/MsgCoder.h"
/* ------------------------------
@@ -57,6 +60,8 @@
protected:
QSocket * _socket;
+ MsgCoder * _send;
+ QString _playerName;
};
Index: camino/src/common/MsgDecoder.h
diff -u camino/src/common/MsgDecoder.h:1.5 camino/src/common/MsgDecoder.h:1.6
--- camino/src/common/MsgDecoder.h:1.5 Sun Jan 26 13:08:54 2003
+++ camino/src/common/MsgDecoder.h Sun Jan 26 14:39:40 2003
@@ -5,7 +5,7 @@
** MsgDecoder.h
** Decoder for socket msg
**
-** Version : $Id: MsgDecoder.h,v 1.5 2003/01/26 18:08:54 pfremy Exp $
+** Version : $Id: MsgDecoder.h,v 1.6 2003/01/26 19:39:40 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -70,7 +70,7 @@
Then all data received by the socket will be automatically decoded by
the decoder,
which will in turn call the right function
*/
- void slotDecode();
+ virtual void slotDecode();
protected:
QIODevice * _socket;
Index: camino/src/server/CaminoServer.cpp
diff -u camino/src/server/CaminoServer.cpp:1.3
camino/src/server/CaminoServer.cpp:1.4
--- camino/src/server/CaminoServer.cpp:1.3 Sun Jan 26 11:50:09 2003
+++ camino/src/server/CaminoServer.cpp Sun Jan 26 14:39:40 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: CaminoServer.cpp,v 1.3 2003/01/26 16:50:09 pfremy Exp $
+** Version : $Id: CaminoServer.cpp,v 1.4 2003/01/26 19:39:40 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 19/01/2003
@@ -30,12 +30,13 @@
// application specific include files
#include "common/log.h"
+#include "server/Player.h"
CaminoServer::CaminoServer( int port )
: QServerSocket( port )
{
- _num = 0;
+ _num = 0;
_currentSocket = 0;
_theSockets.setAutoDelete( true );
_mapper = new QSignalMapper( this );
@@ -51,10 +52,21 @@
QSocket * uneso = new QSocket;
uneso->setSocket( numSocket );
_theSockets.append( uneso );
+
+
+ _playerList.append( new Player( uneso, this ) );
+ qDebug("Camino Server - player appended to list" );
+
_mapper->setMapping( uneso, _theSockets.count()-1 );
connect( uneso, SIGNAL( readyRead() ), _mapper, SLOT( map() ) );
//connect( uneso, SIGNAL( connectionClosed() ), SLOT(
slot_socketClose() ) );
- emit sig_newPlayer( uneso );
+ //emit sig_newConnection( uneso );
// XXX: uneso->sendConnectionOk();
}
+
+void CaminoServer::recvServerConnect( QString playerName )
+{
+ qDebug("CaminoServer - recv client name : %s", playerName.latin1() );
+}
+
Index: camino/src/server/CaminoServer.h
diff -u camino/src/server/CaminoServer.h:1.3
camino/src/server/CaminoServer.h:1.4
--- camino/src/server/CaminoServer.h:1.3 Sun Jan 26 11:50:09 2003
+++ camino/src/server/CaminoServer.h Sun Jan 26 14:39:40 2003
@@ -5,7 +5,7 @@
** CaminoServer.h
** Server for the game
**
-** Version : $Id: CaminoServer.h,v 1.3 2003/01/26 16:50:09 pfremy Exp $
+** Version : $Id: CaminoServer.h,v 1.4 2003/01/26 19:39:40 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 19/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -34,6 +34,8 @@
#include <qserversocket.h>
#include <qsocket.h>
// application specific include files
+#include "common/MsgDecoder.h"
+#include "server/Player.h"
class QSignalMapper;
@@ -47,18 +49,24 @@
class CaminoServer : public QServerSocket
{
Q_OBJECT
+
public:
/** Constructor */
CaminoServer( int port );
void newConnection ( int numSocket );
+ void recvServerConnect( QString playerName );
+
signals:
void sig_readEvent( int );
- void sig_newPlayer( QSocket * );
+ void sig_newConnection( QSocket * );
void sig_endConnection( QString name );
+ void sig_PlayerConnected( QString playerName, QString clientIP );
+
protected:
+ QPtrList<Player> _playerList;
QPtrList<QSocket> _theSockets;
QSocket * _currentSocket;
QSignalMapper * _mapper;
Index: camino/src/server/ServerDialog.cpp
diff -u camino/src/server/ServerDialog.cpp:1.6
camino/src/server/ServerDialog.cpp:1.7
--- camino/src/server/ServerDialog.cpp:1.6 Sun Jan 26 11:50:09 2003
+++ camino/src/server/ServerDialog.cpp Sun Jan 26 14:39:40 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: ServerDialog.cpp,v 1.6 2003/01/26 16:50:09 pfremy Exp $
+** Version : $Id: ServerDialog.cpp,v 1.7 2003/01/26 19:39:40 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -105,7 +105,7 @@
int portNumber = _ipPortNb->text().toInt();
- qDebug("Port number : %d", portNumber );
+ qDebug("ServerDialog - Port number : %d", portNumber );
_server = new CaminoServer( portNumber );
// connect so that new players appear in the player list
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Camino-devel] camino/src camino.pro client/ClientEngine.cpp c...,
Philippe Fremy <=