00001 /* 00002 svas_server -- virtual World Server of Svas 00003 Copyright (c) 2001, 2002 David Moreno Montero 00004 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, but 00012 WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00019 02111-1307, USA. 00020 00021 */ 00022 00023 #ifndef __BASE_CLIENT__ 00024 #define __BASE_CLIENT__ 00025 00026 #include <thread.h> 00027 #include <socket.h> 00028 #include "log.h" 00029 00030 class World; 00031 00032 /** 00033 * The clients waits for new messages from the net and make the 00034 * desired operation. 00035 */ 00036 class baseClient : public ost::Thread { 00037 protected: 00038 /** The stream from where the data comes */ 00039 ost::TCPStream *stream; 00040 /** Is the client alive? */ 00041 bool alive; 00042 /** The world where the client acts */ 00043 World *world; 00044 00045 public: 00046 baseClient(ost::TCPSocket &sock, World *); 00047 ~baseClient(); 00048 virtual void Run(); 00049 virtual void Final(){ log <<"End of thread!"<<endl; } 00050 00051 /// Checks if the client is alive (the variable) and if the conection is still up 00052 bool isAlive(){ return alive; }; 00053 /// Makes the semphore post, so the thread continue walking 00054 void walk(){ Resume(); }; 00055 void dontWalk(); 00056 00057 /// returns actual world 00058 World *getWorld(){ return world; }; 00059 }; 00060 00061 00062 #endif