/*************************************************************************** * Copyright (C) 1980-2005 Artur Wiebe * * artur@wiebenet.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * 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; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef _CLIENTSOCKET_H_ #define _CLIENTSOCKET_H_ #include #define CLIENT_CREATE 1 #define CLIENT_JOIN 2 class myClientSocket : public QSocket { Q_OBJECT public: myClientSocket(const QString& ip, int port); ~myClientSocket(); bool sendText(const QString& data); bool isConnected() const { return m_state==sConnectionOk; } void disc(); void joinOrCreate(int type); signals: void dataInd(const QString& data); void discInd(); void connInd(); // join or create signal void joc(bool); private slots: void slotRead(); void slotConnectionClosed(); void slotConnected(); void slotJocTimeout(); private: bool send(const QString& cmd, const QString& data); private: // sDisconnected - no connection at all. // sConnected - connected to server but not yes verified. // sConnectionOk - server is ok. // sJoining - trying to join a game. // sCreating - trying to create a new game. enum { sDisconnected, sConnected, sConnectionOk, sJoinOrCreate }; int m_state; }; #endif