From kde-commits Fri Sep 30 22:06:08 2005 From: Albert Astals Cid Date: Fri, 30 Sep 2005 22:06:08 +0000 To: kde-commits Subject: branches/work/kde4/playground/games/kombination/src Message-Id: <1128117968.317394.28165.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=112811797608843 SVN commit 465819 by aacid: some less replication more M +16 -20 client.cpp M +2 -0 client.h --- branches/work/kde4/playground/games/kombination/src/client.cpp #465818:465819 @@ -109,18 +109,10 @@ aux = m_stream.readLine(); i = aux.toInt(); - if (i == NEXT_TURN) - { - QString nick = m_stream.readLine(); - emit nextPlayer(nick, nick == m_nick); - } + if (i == NEXT_TURN) handleNextTurn(); else wrongResponse(); } - else if (i == MESSAGE) - { - QString message = m_stream.readLine(); - emit gotMessage(message); - } + else if (i == MESSAGE) handleMessage(); else if (i == NEW_PLAYER) { QString nick = m_stream.readLine(); @@ -130,16 +122,8 @@ break; case PLAYING_GAME: - if (i == NEXT_TURN) - { - QString nick = m_stream.readLine(); - emit nextPlayer(nick, nick == m_nick); - } - else if (i == MESSAGE) - { - QString message = m_stream.readLine(); - emit gotMessage(message); - } + if (i == NEXT_TURN) handleNextTurn(); + else if (i == MESSAGE) handleMessage(); else wrongResponse(); break; } @@ -148,6 +132,18 @@ if (m_clientSocket->bytesAvailable()) slotSocketReadyToRead(); } +void client::handleNextTurn() +{ + QString nick = m_stream.readLine(); + emit nextPlayer(nick, nick == m_nick); +} + +void client::handleMessage() +{ + QString message = m_stream.readLine(); + emit gotMessage(message); +} + void client::sendMessage(const QString &message) { m_stream << MESSAGE << endl; --- branches/work/kde4/playground/games/kombination/src/client.h #465818:465819 @@ -50,6 +50,8 @@ void slotSocketError(int e); private: + void handleNextTurn(); + void handleMessage(); void wrongResponse(); KNetwork::KBufferedSocket *m_clientSocket;