[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Camino-devel] camino/src main.cpp client/ClientEngine.cpp cli...
From: |
Philippe Fremy |
Subject: |
[Camino-devel] camino/src main.cpp client/ClientEngine.cpp cli... |
Date: |
Mon, 17 Feb 2003 17:03:42 -0500 |
CVSROOT: /cvsroot/camino
Module name: camino
Changes by: Philippe Fremy <address@hidden> 03/02/17 17:03:41
Modified files:
src : main.cpp
src/client : ClientEngine.cpp ClientEngine.h Game.cpp Game.h
src/server : Player.cpp ServerDialog.cpp
Log message:
turn ClientEngine into a coder/decoder
detect when server can not start
Patches:
Index: camino/src/client/ClientEngine.cpp
diff -u camino/src/client/ClientEngine.cpp:1.8
camino/src/client/ClientEngine.cpp:1.9
--- camino/src/client/ClientEngine.cpp:1.8 Mon Feb 17 16:33:50 2003
+++ camino/src/client/ClientEngine.cpp Mon Feb 17 17:03:41 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: ClientEngine.cpp,v 1.8 2003/02/17 21:33:50 pfremy Exp $
+** Version : $Id: ClientEngine.cpp,v 1.9 2003/02/17 22:03:41 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -35,12 +35,11 @@
{
_socket = new QSocket( this );
_state = StateNotConnected;
- setDevice( _socket );
+ MsgDecoder::setDevice( _socket );
+ MsgCoder::setDevice( _socket );
connect( _socket, SIGNAL( connected() ), SLOT( slotServerConnected() )
);
connect( _socket, SIGNAL( connectionClosed() ), SLOT(
slotConnectionClosed() ) );
connect( _socket, SIGNAL( readyRead() ), SLOT( slotDecode() ) );
-
- _send = new MsgCoder( _socket );
}
bool ClientEngine::isConnected()
@@ -66,7 +65,7 @@
emit sig_connected( true );
qDebug("ClientEngine - Connection with server established!");
qDebug("ClientEngine - send player name " );
- _send->connectServer( _playerName );
+ connectServer( _playerName );
qDebug("ClientEngine - send player name - done" );
_state = StateWaitStart;
}
@@ -101,25 +100,25 @@
emit sig_message( text );
}
-void ClientEngine::sendMessage( const QString & msg )
+void ClientEngine::sendMessage( NetMsgSubtype msgLevel, const QString & msg )
{
- _send->sendMsg( InfoMsg, _playerName, msg );
+ sendMsg( msgLevel, _playerName, msg );
}
void ClientEngine::sendUndo()
{
if( _state == StatePlay ) {
- _send->sendUndo();
+ sendUndo();
_state = StateUndoProcessing;
}
}
void ClientEngine::slotDecode()
{
- qDebug( "ClientEngine::slotDecode()" );
+// qDebug( "ClientEngine::slotDecode()" );
MsgDecoder::slotDecode();
- qDebug( "bytes available : %ld", _socket->bytesAvailable() );
+// 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.7
camino/src/client/ClientEngine.h:1.8
--- camino/src/client/ClientEngine.h:1.7 Mon Feb 17 16:33:50 2003
+++ camino/src/client/ClientEngine.h Mon Feb 17 17:03:41 2003
@@ -5,7 +5,7 @@
** ClientEngine.h
** The intelligence of the client is here
**
-** Version : $Id: ClientEngine.h,v 1.7 2003/02/17 21:33:50 pfremy Exp $
+** Version : $Id: ClientEngine.h,v 1.8 2003/02/17 22:03:41 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -44,7 +44,7 @@
class QSocket;
/** comment for the class */
-class ClientEngine : public MsgDecoder
+class ClientEngine : public MsgDecoder, public MsgCoder
{
Q_OBJECT
@@ -58,7 +58,7 @@
void recvMsg( QString source, QString msg );
- void sendMessage( const QString & msg );
+ void sendMessage( NetMsgSubtype msgLevel, const QString & msg );
void sendUndo();
@@ -82,7 +82,6 @@
StatePlay
} _state;
QSocket * _socket;
- MsgCoder * _send;
QString _playerName;
};
Index: camino/src/client/Game.cpp
diff -u camino/src/client/Game.cpp:1.12 camino/src/client/Game.cpp:1.13
--- camino/src/client/Game.cpp:1.12 Thu Feb 6 15:33:59 2003
+++ camino/src/client/Game.cpp Mon Feb 17 17:03:41 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: Game.cpp,v 1.12 2003/02/06 20:33:59 Audoux Exp $
+** Version : $Id: Game.cpp,v 1.13 2003/02/17 22:03:41 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 15/01/2003
@@ -61,7 +61,7 @@
_board->addTile( 1, 1 );
- connect( _chat, SIGNAL( sig_message( const QString & ) ), SLOT(
slot_message( const QString & ) ) );
+ connect( _chat, SIGNAL( sig_message( const QString & ) ), SLOT(
slot_chatMessage( const QString & ) ) );
connect( _engine, SIGNAL( sig_message( const QString & ) ), SLOT(
slot_serverMessage( const QString & ) ) );
connect( _engine, SIGNAL( sig_connected( bool ) ), SIGNAL(
sig_connected( bool ) ) );
@@ -95,11 +95,10 @@
_engine->connectToServer( host, port, player );
}
-void Game::slot_message( const QString & msg )
+void Game::slot_chatMessage( const QString & msg )
{
if( _engine->isConnected() ) {
- _engine->sendMessage( msg );
- _chat->newMessage( msg );
+ _engine->sendMessage( ChatMsg, msg );
} else {
_chat->newMessage( "(Not connected) : " + msg );
}
Index: camino/src/client/Game.h
diff -u camino/src/client/Game.h:1.10 camino/src/client/Game.h:1.11
--- camino/src/client/Game.h:1.10 Thu Feb 6 15:33:59 2003
+++ camino/src/client/Game.h Mon Feb 17 17:03:41 2003
@@ -5,7 +5,7 @@
** Game.h
** Main widget of the game
**
-** Version : $Id: Game.h,v 1.10 2003/02/06 20:33:59 Audoux Exp $
+** Version : $Id: Game.h,v 1.11 2003/02/17 22:03:41 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 15/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -62,7 +62,7 @@
void reupdate();
public slots:
- void slot_message( const QString & msg );
+ void slot_chatMessage( const QString & msg );
void slot_serverMessage( const QString & msg );
Index: camino/src/main.cpp
diff -u camino/src/main.cpp:1.4 camino/src/main.cpp:1.5
--- camino/src/main.cpp:1.4 Mon Feb 17 16:33:17 2003
+++ camino/src/main.cpp Mon Feb 17 17:03:41 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: main.cpp,v 1.4 2003/02/17 21:33:17 pfremy Exp $
+** Version : $Id: main.cpp,v 1.5 2003/02/17 22:03:41 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -79,6 +79,10 @@
if ( startServer == true ) {
clientWindow.hide();
CaminoServer * server = new CaminoServer( port, 2 );
+ if ( ! server->ok() ) {
+ qDebug( "Could not create server, port is probably
still in use" );
+ return 1;
+ }
ServerWidget * serverWidget = new ServerWidget( server );
serverWidget->hide();
Index: camino/src/server/Player.cpp
diff -u camino/src/server/Player.cpp:1.6 camino/src/server/Player.cpp:1.7
--- camino/src/server/Player.cpp:1.6 Mon Feb 17 16:33:50 2003
+++ camino/src/server/Player.cpp Mon Feb 17 17:03:41 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: Player.cpp,v 1.6 2003/02/17 21:33:50 pfremy Exp $
+** Version : $Id: Player.cpp,v 1.7 2003/02/17 22:03:41 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -43,11 +43,11 @@
void Player::slotDecode()
{
- qDebug("Player - slotDecode()");
+// qDebug("Player - slotDecode()");
// notify server which socket is speaking
MsgDecoder::slotDecode();
- qDebug( "bytes available : %ld", _socket->bytesAvailable() );
+ //qDebug( "bytes available : %ld", _socket->bytesAvailable() );
if ( _socket->bytesAvailable() ) {
MsgDecoder::slotDecode();
}
Index: camino/src/server/ServerDialog.cpp
diff -u camino/src/server/ServerDialog.cpp:1.9
camino/src/server/ServerDialog.cpp:1.10
--- camino/src/server/ServerDialog.cpp:1.9 Tue Jan 28 16:54:27 2003
+++ camino/src/server/ServerDialog.cpp Mon Feb 17 17:03:41 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: ServerDialog.cpp,v 1.9 2003/01/28 21:54:27 pfremy Exp $
+** Version : $Id: ServerDialog.cpp,v 1.10 2003/02/17 22:03:41 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -116,6 +116,13 @@
qDebug("ServerDialog - starting server on port : %d", portNumber );
_server = new CaminoServer( portNumber, _nb );
+
+ if ( ! _server->ok() ) {
+ // XXX if the socket is in use
+ // do something
+ qDebug( "could not create server, the socket is probably still
in use" );
+ }
+
_serverWidget = new ServerWidget( _server );
_serverWidget->hide();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Camino-devel] camino/src main.cpp client/ClientEngine.cpp cli...,
Philippe Fremy <=