Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

baseClient.cc

Go to the documentation of this file.
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 #include <thread.h>
00024 #include <math.h>
00025 #include "baseClient.h"
00026 #include "log.h"
00027 #include "world.h"
00028 
00029 /**
00030  * Creates the stream from the socket 
00031  */
00032 baseClient::baseClient(ost::TCPSocket &sock, World *_world){
00033   log <<"New Client!!!!!"<<endl;
00034 
00035   stream=new ost::TCPStream(sock);
00036   alive=true;
00037   world=_world;
00038 }
00039 
00040 /** 
00041  * Destroys the client
00042  */
00043 baseClient::~baseClient(){
00044   log <<"Destroy of client!!!"<<endl;
00045   if (NULL!=stream)
00046     delete stream;
00047 }
00048 
00049 /** 
00050  * Runs the wait-for-messages loop
00051  */
00052 void baseClient::Run(){
00053   log <<"run!"<<endl;
00054 
00055   while(stream->ipfx()!=0){
00056     string st;
00057     *stream >> st;
00058     log <<"client: "<<st<<endl;
00059   }
00060   log <<"client out!"<<endl;
00061   alive=false;
00062 }
00063 
00064 /// Makes the execution of the thread stop, and the numClients counter
00065 /// increment
00066 void baseClient::dontWalk(){ 
00067   world->numClients-=1; 
00068   Suspend(); 
00069 };

Generated on Mon Jun 17 19:53:43 2002 for Svas Server by doxygen1.2.16