bool ClientMain::requestService (  )  [private]

Definition at line 102 of file ClientMain.cpp.

00102                                 {
00103         if (!serviceNeeded && allowRequestService) {
00104                 cout << DateFormater::getDate() << "Requesting for a new service to be done..." << endl;
00105                 try {
00106                         ServiceRequest serviceRequest;
00107                         Message response;
00108                         if (sendAndReceive("main",serviceRequest,response)) {
00109                                 bool found = false;
00110                                 if ( !found ) try {
00111                                         ServiceOffer so = response;
00112                                         if (pServiceOffer!=0) {
00113                                                 delete pServiceOffer;
00114                                         }
00115                                         pServiceOffer = new ServiceOffer(response);
00116                                         serviceNeeded = true;
00117                                         cout << DateFormater::getDate() << "Received service offer from the server." << endl;
00118                                         found = true;
00119                                 }
00120                                 catch ( MessageCastException& e ) {}
00121                                 if ( !found ) try {
00122                                         NoServiceNeeded temp = response;
00123                                         serviceNeeded = false;
00124                                         cout << DateFormater::getDate() << "No service needed by the server." << endl;
00125                                         found = true;
00126                                 }
00127                                 catch ( MessageCastException& e ) {}
00128                                 if ( !found ) {
00129                                         serviceNeeded = false;
00130                                         cout << DateFormater::getDate() << "Unexpected answer from the server." << endl;
00131                                 }
00132                                 return serviceNeeded;
00133                         }
00134                         else {
00135                                 cout << DateFormater::getDate() << "Can't communicate with server." << endl;
00136                         }
00137                 }
00138                 catch ( NetInterfaceException& e ) {
00139                         cout << DateFormater::getDate() << "Request connection failed..." << endl;
00140                         cout << DateFormater::getDate() << "NetInterface: ";
00141                         e.print();
00142                         return false;
00143                 }
00144         }
00145         else if (allowRequestService) {
00146                 cout << DateFormater::getDate() << "There is already a service needed..." << endl;
00147                 return true;
00148         }
00149         else {
00150                 return false;
00151         }
00152 }


Generated on Wed Jun 25 14:47:08 2008 for keyvil by  doxygen 1.5.1