[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Camino-devel] camino/src client/ClientEngine.cpp client/Clien...
From: |
Philippe Fremy |
Subject: |
[Camino-devel] camino/src client/ClientEngine.cpp client/Clien... |
Date: |
Mon, 17 Feb 2003 16:33:50 -0500 |
CVSROOT: /cvsroot/camino
Module name: camino
Changes by: Philippe Fremy <address@hidden> 03/02/17 16:33:50
Modified files:
src/client : ClientEngine.cpp ClientEngine.h
ClientInterface.cpp ClientInterface.h
src/server : CaminoServer.cpp Player.cpp Player.h
ServerWidget.cpp
Log message:
Chat is now working
Patches:
Index: camino/src/client/ClientEngine.cpp
diff -u camino/src/client/ClientEngine.cpp:1.7
camino/src/client/ClientEngine.cpp:1.8
--- camino/src/client/ClientEngine.cpp:1.7 Thu Jan 30 16:42:58 2003
+++ camino/src/client/ClientEngine.cpp Mon Feb 17 16:33:50 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: ClientEngine.cpp,v 1.7 2003/01/30 21:42:58 Audoux Exp $
+** Version : $Id: ClientEngine.cpp,v 1.8 2003/02/17 21:33:50 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -114,6 +114,15 @@
}
}
+void ClientEngine::slotDecode()
+{
+ qDebug( "ClientEngine::slotDecode()" );
+ MsgDecoder::slotDecode();
+ qDebug( "bytes available : %ld", _socket->bytesAvailable() );
+ if ( _socket->bytesAvailable() ) {
+ MsgDecoder::slotDecode();
+ }
+}
Index: camino/src/client/ClientEngine.h
diff -u camino/src/client/ClientEngine.h:1.6
camino/src/client/ClientEngine.h:1.7
--- camino/src/client/ClientEngine.h:1.6 Thu Jan 30 16:42:58 2003
+++ camino/src/client/ClientEngine.h Mon Feb 17 16:33:50 2003
@@ -5,7 +5,7 @@
** ClientEngine.h
** The intelligence of the client is here
**
-** Version : $Id: ClientEngine.h,v 1.6 2003/01/30 21:42:58 Audoux Exp $
+** Version : $Id: ClientEngine.h,v 1.7 2003/02/17 21:33:50 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -70,6 +70,7 @@
protected slots:
void slotServerConnected();
void slotConnectionClosed();
+ void slotDecode();
protected:
enum StateClient {
Index: camino/src/client/ClientInterface.cpp
diff -u camino/src/client/ClientInterface.cpp:1.19
camino/src/client/ClientInterface.cpp:1.20
--- camino/src/client/ClientInterface.cpp:1.19 Tue Feb 4 16:04:12 2003
+++ camino/src/client/ClientInterface.cpp Mon Feb 17 16:33:50 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: ClientInterface.cpp,v 1.19 2003/02/04 21:04:12 Audoux Exp $
+** Version : $Id: ClientInterface.cpp,v 1.20 2003/02/17 21:33:50 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 15/01/2003
@@ -50,7 +50,8 @@
extern Theme theme;
extern CaminoSettings settings;
-ClientInterface::ClientInterface()
+ClientInterface::ClientInterface( bool connectImmediately,
+ QString host, int port, QString player )
{
_clientEngine = new ClientEngine();
_serverDialog = 0;
@@ -68,6 +69,10 @@
zoom( 2 );
connect( _game, SIGNAL( sig_connected( bool ) ), SLOT( slot_connected(
bool ) ) );
+
+ if ( connectImmediately ) {
+ _game->connectToServer( host, port, player );
+ }
}
ClientInterface::~ClientInterface()
@@ -195,7 +200,7 @@
return;
}
- // add a test on server.
+ // XXX check if server alraedy exists
_serverDialog = new ServerDialog( this );
connect( _serverDialog, SIGNAL( sig_quit() ), SLOT(
slot_quitServerDialog() ) );
Index: camino/src/client/ClientInterface.h
diff -u camino/src/client/ClientInterface.h:1.13
camino/src/client/ClientInterface.h:1.14
--- camino/src/client/ClientInterface.h:1.13 Sat Feb 1 10:47:14 2003
+++ camino/src/client/ClientInterface.h Mon Feb 17 16:33:50 2003
@@ -5,7 +5,7 @@
** ClientInterface.h
** Interface of the client
**
-** Version : $Id: ClientInterface.h,v 1.13 2003/02/01 15:47:14 Audoux Exp $
+** Version : $Id: ClientInterface.h,v 1.14 2003/02/17 21:33:50 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -52,7 +52,9 @@
Q_OBJECT
public:
/** Constructor */
- ClientInterface();
+ ClientInterface( bool connectImmediately = false,
+ QString host="", int port=0, QString player="" );
+
/** Destructor */
virtual ~ClientInterface();
Index: camino/src/server/CaminoServer.cpp
diff -u camino/src/server/CaminoServer.cpp:1.8
camino/src/server/CaminoServer.cpp:1.9
--- camino/src/server/CaminoServer.cpp:1.8 Tue Jan 28 16:54:27 2003
+++ camino/src/server/CaminoServer.cpp Mon Feb 17 16:33:50 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: CaminoServer.cpp,v 1.8 2003/01/28 21:54:27 pfremy Exp $
+** Version : $Id: CaminoServer.cpp,v 1.9 2003/02/17 21:33:50 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 19/01/2003
@@ -36,6 +36,7 @@
CaminoServer::CaminoServer( int port, int playerNb )
: QServerSocket( port )
{
+ _playerList.setAutoDelete( true );
_playerNb = playerNb;
_state = WaitingForConnection;
}
@@ -62,6 +63,7 @@
it.current()->sendMsg( msgLevel, source, msg );
++it;
}
+ emit sig_msg( msgLevel, source, msg );
}
bool CaminoServer::isPlayerNameValid( QString playerName )
@@ -92,7 +94,8 @@
return;
}
- serverBroadcastMsg( InfoMsg, "Distributing tiles" );
+ qDebug( "Begin Party" );
+ serverBroadcastMsg( InfoMsg, "Begin Party" );
_state = BeginParty;
// ...
Index: camino/src/server/Player.cpp
diff -u camino/src/server/Player.cpp:1.5 camino/src/server/Player.cpp:1.6
--- camino/src/server/Player.cpp:1.5 Wed Jan 29 17:11:27 2003
+++ camino/src/server/Player.cpp Mon Feb 17 16:33:50 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: Player.cpp,v 1.5 2003/01/29 22:11:27 pfremy Exp $
+** Version : $Id: Player.cpp,v 1.6 2003/02/17 21:33:50 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -46,18 +46,23 @@
qDebug("Player - slotDecode()");
// notify server which socket is speaking
MsgDecoder::slotDecode();
+
+ qDebug( "bytes available : %ld", _socket->bytesAvailable() );
+ if ( _socket->bytesAvailable() ) {
+ MsgDecoder::slotDecode();
+ }
}
void Player::recvServerConnect( QString playerName )
{
- // normally, this a client can not connect a server if it has enough
players.
-
+ // normally, a client can not connect a server if it has enough players.
if ( _server->isPlayerNameValid( playerName ) == false ) {
_server->serverBroadcastMsg( InfoMsg,
QString( "rejects connection with existing player name
%1").arg(playerName)
);
_socket->close();
+ _server->_playerList.remove( this );
return;
}
@@ -79,22 +84,9 @@
}
}
-void Player::playerBroadcastMsg( NetMsgSubtype msgLevel, QString msg )
-{
-// _server->broadcastMsg( msgLevel, getPlayerName(), msg);
- QPtrListIterator<Player> it( _server->_playerList );
- while( it.current() ) {
- if (it.current() != this) {
- it.current()->sendMsg( msgLevel, getPlayerName(), msg );
- ++it;
- }
- }
-}
-
void Player::recvMsg( QString source, QString msg )
{
- _server->sig_msg( _subtype, source, msg );
- playerBroadcastMsg( _subtype, msg );
+ _server->broadcastMsg( _subtype, source, msg );
}
Index: camino/src/server/Player.h
diff -u camino/src/server/Player.h:1.5 camino/src/server/Player.h:1.6
--- camino/src/server/Player.h:1.5 Wed Jan 29 17:11:27 2003
+++ camino/src/server/Player.h Mon Feb 17 16:33:50 2003
@@ -5,7 +5,7 @@
** Player.h
** this is a template for all .h files
**
-** Version : $Id: Player.h,v 1.5 2003/01/29 22:11:27 pfremy Exp $
+** Version : $Id: Player.h,v 1.6 2003/02/17 21:33:50 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -53,8 +53,6 @@
void setPlayerName( QString & playerName ) { _playerName = playerName; }
const QString & getPlayerName() { return _playerName; }
-
- void playerBroadcastMsg( NetMsgSubtype msgLevel, QString msg );
virtual void slotDecode();
virtual void recvServerConnect( QString playerName );
Index: camino/src/server/ServerWidget.cpp
diff -u camino/src/server/ServerWidget.cpp:1.1
camino/src/server/ServerWidget.cpp:1.2
--- camino/src/server/ServerWidget.cpp:1.1 Tue Jan 28 16:52:17 2003
+++ camino/src/server/ServerWidget.cpp Mon Feb 17 16:33:50 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: ServerWidget.cpp,v 1.1 2003/01/28 21:52:17 pfremy Exp $
+** Version : $Id: ServerWidget.cpp,v 1.2 2003/02/17 21:33:50 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -41,16 +41,19 @@
setCaption( "Camino Server" );
- resize( 400, 500 );
+ resize( 400, 700 );
+ /*
slot_appendMsg( InfoMsg, "Server", "Game started!" );
slot_appendMsg( DebugMsg, "Server", "some debug stuff!" );
slot_appendMsg( ChatMsg, "Server", "coucou, c'est moi!" );
+ */
}
void ServerWidget::slot_appendMsg( NetMsgSubtype level, QString source,
QString msg )
{
- QString logS = "<%1><b>%3</b>\t%4\t - %5</%2>";
+ //QString logS = "<%1><b>%3</b>\t%4\t - %5</%2>";
+ QString logS = "<%1>%4 - %3 - %5</%2>";
QString s;
switch( level ) {
case DebugMsg:
- [Camino-devel] camino/src client/ClientEngine.cpp client/Clien...,
Philippe Fremy <=