/*************************************************************************** * 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 _SERVERSOCKET_H_ #define _SERVERSOCKET_H_ #include #include class mySocket; #define KW_LEN 4 // length of keywords #define S_VER "sver" // server version #define S_CREATE "crea" // create new game #define S_JOIN "join" // join an existing game #define S_HELP "help" #define S_DATA "data" // data between client and server #define S_DISC "disc" // disconnect #define C_ACK "okay" // positive ack #define C_NACK "nack" // negative ack #define C_LEFT "left" // opponent left #define NETWORK_NL '\n' class myServerSocket : public QServerSocket { Q_OBJECT public: myServerSocket(int port); virtual ~myServerSocket(); virtual void newConnection(int); private slots: void slotReadClient(); void slotClientDisconnected(); private: void send(mySocket*, const QString& data); void rm_socket(mySocket*); private: mySocket* m_server; mySocket* m_client; }; class mySocket : public QSocket { Q_OBJECT public: mySocket(QObject* parent) : QSocket(parent) { m_type=tNone; m_other=0; } enum { tServer, tClient, tNone }; int type() const { return m_type; } void setType(int t) { m_type = t; } void setOther(mySocket* s) { m_other = s; } mySocket* other() const { return m_other; } private: int m_type; mySocket* m_other; }; #endif