00001 /******************************************************************** 00002 Description: 00003 part of the 3Dsia project 00004 created: StonedBones, 31.1.2000 00005 00006 History: 00007 date, name, changes, in funtion 00008 170400 xandi added coreBufIn/Out buffers (Xandi: you wrote 270400 ??) 00009 040400 xandi removed coreBufIn/Out buffes 00010 removed entire user-handling code 00011 310100 StonedBones created source 00012 00013 ********************************************************************/ 00014 00015 #include "clientControlThread.h" 00016 00017 #include <pthread.h> 00018 #include <unistd.h> 00019 00020 #include "../common/intToChar.h" 00021 #include "../common/buffer.h" 00022 #include "../common/generic.h" 00023 00024 #include "frontEnd.h" 00025 #include "network.h" 00026 #include "clientThread.h" 00027 00028 00029 Network* network; 00030 00031 /*................................................................... 00032 Description: The Client Control Thread (CCT) 00033 Args: CCTArgs* args: various arguments (see header-file) 00034 Returns: <none> 00035 Created: StonedBones, 31.1.2000 00036 ToDo: 00037 all the user-info-handling should be done by ODB, xandi 00038 [Comments:] 00039 Changes: 00040 removed the entire user-handling code (sorry to destroy your 00041 effors marc ;), 040400, xandi 00042 -------------------------------------------------------------------*/ 00043 00044 00045 map<int,Buffer*> clientBufferIn; 00046 00047 void* ClientControlThread ( void* argz ) 00048 { 00049 // CCTArgs* args = (CCTArgs*) argz; 00050 00051 extern FrontEnd* frontEnd; 00052 00053 int clientSock; 00054 00055 frontEnd->displayDebugMessage ("ClientControlThread started"); 00056 frontEnd->displayUsers (0); 00057 frontEnd->displayMatrices (0); 00058 00059 network = new Network (); 00060 00061 string msg; 00062 pthread_t* cThread; 00063 00064 while (1) 00065 { 00066 clientSock = network->waitForConnection (); 00067 00068 msg = "Connection established on socket "; 00069 msg += intToChar (clientSock); 00070 frontEnd->displayDebugMessage (msg.c_str ()); 00071 // frontEnd->displayUsers (clientsConnected); 00072 00073 cThread = new pthread_t; 00074 00075 if ( clientBufferIn[clientSock] ) 00076 delete clientBufferIn[clientSock]; 00077 clientBufferIn[clientSock] = new Buffer (); 00078 00079 if (pthread_create (cThread, NULL, ClientThread, &clientSock) != 0) 00080 { 00081 frontEnd->displayDebugMessage ("Error: can't create client thread !"); 00082 } 00083 00084 00085 } 00086 return argz; 00087 } 00088